diff options
author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-05-25 17:33:28 +0900 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2012-05-25 23:06:08 +0200 |
commit | b061fed981c97bef78679f193173ab55a4dce91e (patch) | |
tree | a64b568cba77c5eee1ced652fdbd0ce9dd6ad4f4 /src/tool_cb_hdr.c | |
parent | 9c480490f7559e169cea59754480f87d2763e2c2 (diff) |
Made -D option work with -O and -J.
To achieve this, first new structure HeaderData is defined to hold
necessary data to perform header-related work. Then tool_header_cb now
receives HeaderData pointer as userdata. All header-related work
(currently, dumping header and Content-Disposition inspection) are done
in this callback function. HeaderData.outs->config is used to determine
whether each work is done.
Unit tests were also updated because after this change, curl code always
sets CURLOPT_HEADERFUNCTION and CURLOPT_HEADERDATA.
Tested with -O -J -D, -O -J -i and -O -J -D -i and all worked fine.
Diffstat (limited to 'src/tool_cb_hdr.c')
-rw-r--r-- | src/tool_cb_hdr.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c index e96331177..738cd5dfc 100644 --- a/src/tool_cb_hdr.c +++ b/src/tool_cb_hdr.c @@ -41,7 +41,10 @@ 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) { - struct OutStruct *outs = userdata; + HeaderData *hdrdata = userdata; + struct getout *urlnode = hdrdata->urlnode; + struct OutStruct *outs = hdrdata->outs; + struct OutStruct *heads = hdrdata->heads; const char *str = ptr; const size_t cb = size * nmemb; const char *end = (char*)ptr + cb; @@ -63,8 +66,13 @@ size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata) return failure; } #endif + /* --dump-header option */ + if(outs->config->headerfile) { + fwrite(ptr, size, nmemb, heads->stream); + } - if((cb > 20) && checkprefix("Content-disposition:", str)) { + if((urlnode->flags & GETOUT_USEREMOTE) && outs->config->content_disposition + && (cb > 20) && checkprefix("Content-disposition:", str)) { const char *p = str + 20; /* look for the 'filename=' parameter |