Loading src/tool_cb_hdr.c +20 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading src/tool_cb_wrt.c +2 −2 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata) /* standard stream */ if(!outs->stream || outs->s_isreg || outs->fopened) check_fails = TRUE; if(outs->alloc_filename || outs->init) if(outs->alloc_filename || outs->is_cd_filename || outs->init) check_fails = TRUE; } if(check_fails) { Loading @@ -104,7 +104,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata) return failure; } if(config->content_disposition) { if(outs->is_cd_filename) { /* don't overwrite existing files */ file = fopen(outs->filename, "rb"); if(file) { Loading src/tool_operate.c +1 −1 Original line number Diff line number Diff line Loading @@ -1309,7 +1309,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) for(;;) { res = curl_easy_perform(curl); if(config->content_disposition && outs.stream && !config->mute && if(outs.is_cd_filename && outs.stream && !config->mute && outs.filename) printf("curl: Saved to filename '%s'\n", outs.filename); Loading src/tool_sdecls.h +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ * 'alloc_filename' member is TRUE when string pointed by 'filename' has been * dynamically allocated and 'belongs' to this OutStruct, otherwise FALSE. * * 'is_cd_filename' member is TRUE when string pointed by 'filename' has been * set using a server-specified Content-Disposition filename, otherwise FALSE. * * 's_isreg' member is TRUE when output goes to a regular file, this also * implies that output is 'seekable' and 'appendable' and also that member * 'filename' points to file name's string. For any standard stream member Loading @@ -57,6 +60,7 @@ struct OutStruct { char *filename; bool alloc_filename; bool is_cd_filename; bool s_isreg; bool fopened; FILE *stream; Loading tests/data/DISABLED +0 −5 Original line number Diff line number Diff line Loading @@ -22,16 +22,11 @@ 1361 1362 # 1338 1339 # 1370 1371 1385 1393 # 1368 1369 1379 1380 1381 Loading Loading
src/tool_cb_hdr.c +20 −2 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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; Loading
src/tool_cb_wrt.c +2 −2 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata) /* standard stream */ if(!outs->stream || outs->s_isreg || outs->fopened) check_fails = TRUE; if(outs->alloc_filename || outs->init) if(outs->alloc_filename || outs->is_cd_filename || outs->init) check_fails = TRUE; } if(check_fails) { Loading @@ -104,7 +104,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata) return failure; } if(config->content_disposition) { if(outs->is_cd_filename) { /* don't overwrite existing files */ file = fopen(outs->filename, "rb"); if(file) { Loading
src/tool_operate.c +1 −1 Original line number Diff line number Diff line Loading @@ -1309,7 +1309,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) for(;;) { res = curl_easy_perform(curl); if(config->content_disposition && outs.stream && !config->mute && if(outs.is_cd_filename && outs.stream && !config->mute && outs.filename) printf("curl: Saved to filename '%s'\n", outs.filename); Loading
src/tool_sdecls.h +4 −0 Original line number Diff line number Diff line Loading @@ -34,6 +34,9 @@ * 'alloc_filename' member is TRUE when string pointed by 'filename' has been * dynamically allocated and 'belongs' to this OutStruct, otherwise FALSE. * * 'is_cd_filename' member is TRUE when string pointed by 'filename' has been * set using a server-specified Content-Disposition filename, otherwise FALSE. * * 's_isreg' member is TRUE when output goes to a regular file, this also * implies that output is 'seekable' and 'appendable' and also that member * 'filename' points to file name's string. For any standard stream member Loading @@ -57,6 +60,7 @@ struct OutStruct { char *filename; bool alloc_filename; bool is_cd_filename; bool s_isreg; bool fopened; FILE *stream; Loading
tests/data/DISABLED +0 −5 Original line number Diff line number Diff line Loading @@ -22,16 +22,11 @@ 1361 1362 # 1338 1339 # 1370 1371 1385 1393 # 1368 1369 1379 1380 1381 Loading