diff options
author | Daniel Stenberg <daniel@haxx.se> | 2007-09-26 12:44:59 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2007-09-26 12:44:59 +0000 |
commit | fd4cf78f36e89b8a0913e4fb34fd7a89f5c0cfd4 (patch) | |
tree | c4a2dfb16d9985c715a6f4b2a6dfbe7edd2dc1c4 /src | |
parent | a6315359d742bdf967ba3ee1db3e0b7e5a3956fe (diff) |
Philip Langdale provided the new CURLOPT_POST301 option for
curl_easy_setopt() that alters how libcurl functions when following
redirects. It makes libcurl obey the RFC2616 when a 301 response is received
after a non-GET request is made. Default libcurl behaviour is to change
method to GET in the subsequent request (like it does for response code 302
- because that's what many/most browsers do), but with this CURLOPT_POST301
option enabled it will do what the spec says and do the next request using
the same method again. I.e keep POST after 301.
The curl tool got this option as --post301
Test case 1011 and 1012 were added to verify.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/main.c b/src/main.c index 1fffb9695..cf68e845b 100644 --- a/src/main.c +++ b/src/main.c @@ -478,6 +478,7 @@ struct Configurable { char *libcurl; /* output libcurl code to this file name */ bool raw; + bool post301; struct OutStruct *outs; }; @@ -687,6 +688,7 @@ static void help(void) " --no-sessionid Disable SSL session-ID reusing (SSL)", " -o/--output <file> Write output to <file> instead of stdout", " -O/--remote-name Write output to a file named as the remote file", + " --post301 Do not switch to GET after following a 301 redirect (H)", " -p/--proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)", " --proxy-anyauth Pick \"any\" proxy authentication method (H)", " --proxy-basic Use Basic authentication on the proxy (H)", @@ -1511,6 +1513,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ {"$j", "ftp-ssl-ccc-mode", TRUE}, {"$z", "libcurl", TRUE}, {"$#", "raw", FALSE}, + {"$0", "post301", FALSE}, {"0", "http1.0", FALSE}, {"1", "tlsv1", FALSE}, @@ -1962,6 +1965,9 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ case '#': /* --raw */ config->raw ^= TRUE; break; + case '0': /* --post301 */ + config->post301 ^= TRUE; + break; } break; case '#': /* --progress-bar */ @@ -2046,7 +2052,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ if(curlx_strequal("-", nextarg)) { file = stdin; - if(subletter == 'b') /* forced binary */ + if(subletter == 'b') /* forced data-binary */ SET_BINMODE(stdin); } else { @@ -3801,7 +3807,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[]) clean_getout(config); break; } - } + } infiles = urlnode->infile; @@ -4022,17 +4028,17 @@ operate(struct Configurable *config, int argc, argv_item_t argv[]) /* Free the list of remaining URLs and globbed upload files * to force curl to exit immediately */ - if(urls) { - glob_cleanup(urls); - urls = NULL; - } - if(inglob) { - glob_cleanup(inglob); - inglob = NULL; - } - - res = CURLE_READ_ERROR; - goto quit_urls; + if(urls) { + glob_cleanup(urls); + urls = NULL; + } + if(inglob) { + glob_cleanup(inglob); + inglob = NULL; + } + + res = CURLE_READ_ERROR; + goto quit_urls; } infdfopen=TRUE; uploadfilesize=fileinfo.st_size; @@ -4196,7 +4202,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[]) my_setopt(curl, CURLOPT_SSLKEYTYPE, config->key_type); my_setopt(curl, CURLOPT_KEYPASSWD, config->key_passwd); - /* SSH private key uses the same command-line option as SSL private key */ + /* SSH private key uses the same command-line option as SSL private key */ my_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, config->key); my_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, config->pubkey); @@ -4386,6 +4392,9 @@ operate(struct Configurable *config, int argc, argv_item_t argv[]) my_setopt(curl, CURLOPT_HTTP_TRANSFER_DECODING, FALSE); } + /* curl 7.17.1 */ + my_setopt(curl, CURLOPT_POST301, config->post301); + retry_numretries = config->req_retry; retrystart = cutil_tvnow(); |