aboutsummaryrefslogtreecommitdiff
path: root/src/tool_cb_hdr.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2012-06-09 05:42:39 +0200
committerYang Tse <yangsita@gmail.com>2012-06-09 05:49:49 +0200
commita884ffe43027e837e9fef41626c34e7f00bb2df1 (patch)
tree646933b193f8461eb2f33ade7f542ebe57ad397f /src/tool_cb_hdr.c
parentc29d1f4e3ad2152d6bdc990c45454a3a5b3bd224 (diff)
Fixes allowing 26 more test cases in 1334 to 1393 range to succeed
Diffstat (limited to 'src/tool_cb_hdr.c')
-rw-r--r--src/tool_cb_hdr.c46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c
index ddc4c6638..ef340f798 100644
--- a/src/tool_cb_hdr.c
+++ b/src/tool_cb_hdr.c
@@ -41,10 +41,9 @@ static char *parse_filename(const char *ptr, size_t len);
size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
{
- HeaderData *hdrdata = userdata;
- struct getout *urlnode = hdrdata->urlnode;
- struct OutStruct *outs = hdrdata->outs;
- struct OutStruct *heads = hdrdata->heads;
+ struct HdrCbData *hdrcbdata = userdata;
+ struct OutStruct *outs = hdrcbdata->outs;
+ struct OutStruct *heads = hdrcbdata->heads;
const char *str = ptr;
const size_t cb = size * nmemb;
const char *end = (char*)ptr + cb;
@@ -57,39 +56,35 @@ size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
*/
size_t failure = (size * nmemb) ? 0 : 1;
- if(!outs->config)
+ if(!heads->config)
return failure;
#ifdef DEBUGBUILD
if(size * nmemb > (size_t)CURL_MAX_HTTP_HEADER) {
- warnf(outs->config, "Header data exceeds single call write limit!\n");
+ warnf(heads->config, "Header data exceeds single call write limit!\n");
return failure;
}
#endif
- /* --dump-header option */
- if(outs->config->headerfile) {
- fwrite(ptr, size, nmemb, heads->stream);
- }
/*
- ** This callback callback MIGHT set the filename upon appropriate
- ** conditions and server specifying filename in Content-Disposition.
- */
-
- if(!outs->config->content_disposition)
- return cb;
-
- if(!urlnode)
- return failure;
+ * Write header data when curl option --dump-header (-D) is given.
+ */
- if(!checkprefix("http://", urlnode->url) &&
- !checkprefix("https://", urlnode->url))
- return cb;
+ if(heads->config->headerfile && heads->stream) {
+ size_t rc = fwrite(ptr, size, nmemb, heads->stream);
+ if(rc != cb)
+ return rc;
+ }
- if(!(urlnode->flags & GETOUT_USEREMOTE))
- return cb;
+ /*
+ * This callback sets the filename where output shall be written when
+ * curl options --remote-name (-O) and --remote-header-name (-J) have
+ * been simultaneously given and additionally server returns an HTTP
+ * Content-Disposition header specifying a filename property.
+ */
- if((cb > 20) && checkprefix("Content-disposition:", str)) {
+ if(hdrcbdata->honor_cd_filename &&
+ (cb > 20) && checkprefix("Content-disposition:", str)) {
const char *p = str + 20;
/* look for the 'filename=' parameter
@@ -123,6 +118,7 @@ size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
outs->s_isreg = TRUE;
outs->fopened = FALSE;
outs->stream = NULL;
+ hdrcbdata->honor_cd_filename = FALSE;
break;
}
else