mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
Fixes allowing HTTP test cases 1338, 1339, 1368 and 1369 to succeed
This commit is contained in:
parent
c41d959ee6
commit
7352ac408b
@ -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);
|
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;
|
const char *p = str + 20;
|
||||||
|
|
||||||
/* look for the 'filename=' parameter
|
/* 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) {
|
if(filename) {
|
||||||
outs->filename = filename;
|
outs->filename = filename;
|
||||||
outs->alloc_filename = TRUE;
|
outs->alloc_filename = TRUE;
|
||||||
|
outs->is_cd_filename = TRUE;
|
||||||
outs->s_isreg = TRUE;
|
outs->s_isreg = TRUE;
|
||||||
outs->fopened = FALSE;
|
outs->fopened = FALSE;
|
||||||
outs->stream = NULL;
|
outs->stream = NULL;
|
||||||
|
@ -86,7 +86,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata)
|
|||||||
/* standard stream */
|
/* standard stream */
|
||||||
if(!outs->stream || outs->s_isreg || outs->fopened)
|
if(!outs->stream || outs->s_isreg || outs->fopened)
|
||||||
check_fails = TRUE;
|
check_fails = TRUE;
|
||||||
if(outs->alloc_filename || outs->init)
|
if(outs->alloc_filename || outs->is_cd_filename || outs->init)
|
||||||
check_fails = TRUE;
|
check_fails = TRUE;
|
||||||
}
|
}
|
||||||
if(check_fails) {
|
if(check_fails) {
|
||||||
@ -104,7 +104,7 @@ size_t tool_write_cb(void *buffer, size_t sz, size_t nmemb, void *userdata)
|
|||||||
return failure;
|
return failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config->content_disposition) {
|
if(outs->is_cd_filename) {
|
||||||
/* don't overwrite existing files */
|
/* don't overwrite existing files */
|
||||||
file = fopen(outs->filename, "rb");
|
file = fopen(outs->filename, "rb");
|
||||||
if(file) {
|
if(file) {
|
||||||
|
@ -1309,7 +1309,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
for(;;) {
|
for(;;) {
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
if(config->content_disposition && outs.stream && !config->mute &&
|
if(outs.is_cd_filename && outs.stream && !config->mute &&
|
||||||
outs.filename)
|
outs.filename)
|
||||||
printf("curl: Saved to filename '%s'\n", outs.filename);
|
printf("curl: Saved to filename '%s'\n", outs.filename);
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@
|
|||||||
* 'alloc_filename' member is TRUE when string pointed by 'filename' has been
|
* 'alloc_filename' member is TRUE when string pointed by 'filename' has been
|
||||||
* dynamically allocated and 'belongs' to this OutStruct, otherwise FALSE.
|
* 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
|
* '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
|
* implies that output is 'seekable' and 'appendable' and also that member
|
||||||
* 'filename' points to file name's string. For any standard stream member
|
* 'filename' points to file name's string. For any standard stream member
|
||||||
@ -57,6 +60,7 @@
|
|||||||
struct OutStruct {
|
struct OutStruct {
|
||||||
char *filename;
|
char *filename;
|
||||||
bool alloc_filename;
|
bool alloc_filename;
|
||||||
|
bool is_cd_filename;
|
||||||
bool s_isreg;
|
bool s_isreg;
|
||||||
bool fopened;
|
bool fopened;
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
|
@ -22,16 +22,11 @@
|
|||||||
1361
|
1361
|
||||||
1362
|
1362
|
||||||
#
|
#
|
||||||
1338
|
|
||||||
1339
|
|
||||||
#
|
|
||||||
1370
|
1370
|
||||||
1371
|
1371
|
||||||
1385
|
1385
|
||||||
1393
|
1393
|
||||||
#
|
#
|
||||||
1368
|
|
||||||
1369
|
|
||||||
1379
|
1379
|
||||||
1380
|
1380
|
||||||
1381
|
1381
|
||||||
|
Loading…
Reference in New Issue
Block a user