diff options
author | Daniel Stenberg <daniel@haxx.se> | 2018-05-17 13:56:35 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-05-21 20:05:05 +0200 |
commit | c1c27625c797cfb7b21128484b4990446c1e92d9 (patch) | |
tree | 7a1e6b2597a10628f7787e16bb850adb09a87fc7 /src/tool_cb_wrt.c | |
parent | 6876ccf90b473480998af4619de5f316fbd63084 (diff) | |
download | curl-c1c27625c797cfb7b21128484b4990446c1e92d9.tar.gz |
curl: show headers in bold
The feature is only enabled if the output is believed to be a tty.
-J: There's some minor differences and improvements in -J handling, as
now J should work with -i and it actually creates a file first using the
initial name and then *renames* that to the one found in
Content-Disposition (if any).
-i: only shows headers for HTTP transfers now (as documented).
Previously it would also show for pieces of the transfer that were HTTP
(for example when doing FTP over a HTTP proxy).
-i: now shows trailers as well. Previously they were not shown at all.
--libcurl: the CURLOPT_HEADER is no longer set, as the header output is
now done in the header callback.
Diffstat (limited to 'src/tool_cb_wrt.c')
-rw-r--r-- | src/tool_cb_wrt.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/tool_cb_wrt.c b/src/tool_cb_wrt.c index 6716ba5cd..476fef9a4 100644 --- a/src/tool_cb_wrt.c +++ b/src/tool_cb_wrt.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -32,7 +32,8 @@ #include "memdebug.h" /* keep this as LAST include */ /* create a local file for writing, return TRUE on success */ -bool tool_create_output_file(struct OutStruct *outs) +bool tool_create_output_file(struct OutStruct *outs, + bool append) { struct GlobalConfig *global = outs->config->global; FILE *file; @@ -42,7 +43,7 @@ bool tool_create_output_file(struct OutStruct *outs) return FALSE; } - if(outs->is_cd_filename) { + if(outs->is_cd_filename && !append) { /* don't overwrite existing files */ file = fopen(outs->filename, "rb"); if(file) { @@ -54,7 +55,7 @@ bool tool_create_output_file(struct OutStruct *outs) } /* open file for writing */ - file = fopen(outs->filename, "wb"); + file = fopen(outs->filename, append?"ab":"wb"); if(!file) { warnf(global, "Failed to create the file %s: %s\n", outs->filename, strerror(errno)); @@ -97,7 +98,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) } } - if(config->include_headers) { + if(config->show_headers) { if(bytes > (size_t)CURL_MAX_HTTP_HEADER) { warnf(config->global, "Header data size exceeds single call write " "limit!\n"); @@ -141,7 +142,7 @@ size_t tool_write_cb(char *buffer, size_t sz, size_t nmemb, void *userdata) } #endif - if(!outs->stream && !tool_create_output_file(outs)) + if(!outs->stream && !tool_create_output_file(outs, FALSE)) return failure; if(is_tty && (outs->bytes < 2000) && !config->terminal_binary_ok) { |