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_operate.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_operate.c')
-rw-r--r-- | src/tool_operate.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/tool_operate.c b/src/tool_operate.c index e3d002133..689ffb2d7 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -504,6 +504,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) long retry_sleep_default; long retry_sleep; char *this_url; + HeaderData hdrdata; outfile = NULL; infdopen = FALSE; @@ -1211,17 +1212,12 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) if(config->proto_redir_present) my_setopt_flags(curl, CURLOPT_REDIR_PROTOCOLS, config->proto_redir); - if((urlnode->flags & GETOUT_USEREMOTE) - && config->content_disposition) { - my_setopt(curl, CURLOPT_HEADERFUNCTION, tool_header_cb); - my_setopt(curl, CURLOPT_HEADERDATA, &outs); - } - else { - /* if HEADERFUNCTION was set to something in the previous loop, it - is important that we set it (back) to NULL now */ - my_setopt(curl, CURLOPT_HEADERFUNCTION, NULL); - my_setopt(curl, CURLOPT_HEADERDATA, config->headerfile?&heads:NULL); - } + hdrdata.urlnode = urlnode; + hdrdata.outs = &outs; + hdrdata.heads = &heads; + + my_setopt(curl, CURLOPT_HEADERFUNCTION, tool_header_cb); + my_setopt(curl, CURLOPT_HEADERDATA, &hdrdata); if(config->resolve) /* new in 7.21.3 */ |