diff options
author | Daniel Stenberg <daniel@haxx.se> | 2008-09-05 16:13:20 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2008-09-05 16:13:20 +0000 |
commit | 18110b519c56a464bca4258332279c580f07a52f (patch) | |
tree | 0818c63153e939254958ebeacce23ac713bd9bba /lib/transfer.c | |
parent | 4c9768565ec3a9baf26ac8a547bca6e42cc64fa5 (diff) |
- Martin Drasar provided the CURLOPT_POSTREDIR patch. It renames
CURLOPT_POST301 (but adds a define for backwards compatibility for you who
don't define CURL_NO_OLDIES). This option allows you to now also change the
libcurl behavior for a HTTP response 302 after a POST to not use GET in the
subsequent request (when CURLOPT_FOLLOWLOCATION is enabled). I edited the
patch somewhat before commit. The curl tool got a matching --post302
option. Test case 1076 was added to verify this.
Diffstat (limited to 'lib/transfer.c')
-rw-r--r-- | lib/transfer.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/transfer.c b/lib/transfer.c index 2fd6d4cf3..ddacb442a 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -2286,7 +2286,7 @@ CURLcode Curl_follow(struct SessionHandle *data, * libcurl gets the page that most user agents would get, libcurl has to * force GET. * - * This behaviour can be overridden with CURLOPT_POST301. + * This behaviour can be overridden with CURLOPT_POSTREDIR. */ if( (data->set.httpreq == HTTPREQ_POST || data->set.httpreq == HTTPREQ_POST_FORM) @@ -2313,7 +2313,18 @@ CURLcode Curl_follow(struct SessionHandle *data, status. When interoperability with such clients is a concern, the 302 status code may be used instead, since most user agents react to a 302 response as described here for 303. + + This behaviour can be overriden with CURLOPT_POSTREDIR */ + if( (data->set.httpreq == HTTPREQ_POST + || data->set.httpreq == HTTPREQ_POST_FORM) + && !data->set.post302) { + infof(data, + "Violate RFC 2616/10.3.3 and switch from POST to GET\n"); + data->set.httpreq = HTTPREQ_GET; + } + break; + case 303: /* See Other */ /* Disable both types of POSTs, since doing a second POST when * following isn't what anyone would want! */ |