summaryrefslogtreecommitdiff
path: root/src/tool_cb_hdr.c
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2012-06-07 21:57:53 +0200
committerYang Tse <yangsita@gmail.com>2012-06-07 21:57:53 +0200
commit7352ac408b6a7b4a1474f52d845fbba70c9644ae (patch)
tree4f4855363470dd2c88c9a53d7079e52298f448f2 /src/tool_cb_hdr.c
parentc41d959ee6d0a22fa6a7272bd32bf04fec839caf (diff)
downloadcurl-7352ac408b6a7b4a1474f52d845fbba70c9644ae.tar.gz
Fixes allowing HTTP test cases 1338, 1339, 1368 and 1369 to succeed
Diffstat (limited to 'src/tool_cb_hdr.c')
-rw-r--r--src/tool_cb_hdr.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c
index 738cd5dfc..ddc4c6638 100644
--- a/src/tool_cb_hdr.c
+++ b/src/tool_cb_hdr.c
@@ -71,8 +71,25 @@ size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
fwrite(ptr, size, nmemb, heads->stream);
}
- if((urlnode->flags & GETOUT_USEREMOTE) && outs->config->content_disposition
- && (cb > 20) && checkprefix("Content-disposition:", str)) {
+ /*
+ ** 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;
+
+ if(!checkprefix("http://", urlnode->url) &&
+ !checkprefix("https://", urlnode->url))
+ return cb;
+
+ if(!(urlnode->flags & GETOUT_USEREMOTE))
+ return cb;
+
+ if((cb > 20) && checkprefix("Content-disposition:", str)) {
const char *p = str + 20;
/* look for the 'filename=' parameter
@@ -102,6 +119,7 @@ size_t tool_header_cb(void *ptr, size_t size, size_t nmemb, void *userdata)
if(filename) {
outs->filename = filename;
outs->alloc_filename = TRUE;
+ outs->is_cd_filename = TRUE;
outs->s_isreg = TRUE;
outs->fopened = FALSE;
outs->stream = NULL;