aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrei Cipu <acipu@ixiacom.com>2012-03-30 10:40:04 +0300
committerDaniel Stenberg <daniel@haxx.se>2012-04-05 23:29:21 +0200
commit0b516b7162dc387ed80b0f24476b950ab2e18cb7 (patch)
tree8dc2ee9ac9e1e21d47122d7ae792c9efb0c25e5f /lib
parenta0b3535735ab29d8064654097058d230882eddc5 (diff)
CURLOPT_POSTREDIR: also allow 303 to do POST on the redirected URL
As it turns out, some people do want that after all.
Diffstat (limited to 'lib')
-rw-r--r--lib/transfer.c11
-rw-r--r--lib/url.c6
-rw-r--r--lib/urldata.h6
3 files changed, 12 insertions, 11 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index d872719fa..20b3d048e 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -1864,7 +1864,7 @@ CURLcode Curl_follow(struct SessionHandle *data,
*/
if((data->set.httpreq == HTTPREQ_POST
|| data->set.httpreq == HTTPREQ_POST_FORM)
- && !data->set.post301) {
+ && !(data->set.keep_post & CURL_REDIR_POST_301)) {
infof(data,
"Violate RFC 2616/10.3.2 and switch from POST to GET\n");
data->set.httpreq = HTTPREQ_GET;
@@ -1892,7 +1892,7 @@ CURLcode Curl_follow(struct SessionHandle *data,
*/
if((data->set.httpreq == HTTPREQ_POST
|| data->set.httpreq == HTTPREQ_POST_FORM)
- && !data->set.post302) {
+ && !(data->set.keep_post & CURL_REDIR_POST_302)) {
infof(data,
"Violate RFC 2616/10.3.3 and switch from POST to GET\n");
data->set.httpreq = HTTPREQ_GET;
@@ -1900,9 +1900,10 @@ CURLcode Curl_follow(struct SessionHandle *data,
break;
case 303: /* See Other */
- /* Disable both types of POSTs, since doing a second POST when
- * following isn't what anyone would want! */
- if(data->set.httpreq != HTTPREQ_GET) {
+ /* Disable both types of POSTs, unless the user explicitely
+ asks for POST after POST */
+ if(data->set.httpreq != HTTPREQ_GET
+ && !(data->set.keep_post & CURL_REDIR_POST_303)) {
data->set.httpreq = HTTPREQ_GET; /* enforce GET request */
infof(data, "Disables POST, goes with %s\n",
data->set.opt_no_body?"HEAD":"GET");
diff --git a/lib/url.c b/lib/url.c
index 01e217cd9..9ae977e11 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -1111,12 +1111,12 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
* CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302
* CURL_REDIR_POST_301 - POST is kept as POST after 301
* CURL_REDIR_POST_302 - POST is kept as POST after 302
- * CURL_REDIR_POST_ALL - POST is kept as POST after 301 and 302
+ * CURL_REDIR_POST_303 - POST is kept as POST after 303
+ * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303
* other - POST is kept as POST after 301 and 302
*/
long postRedir = va_arg(param, long);
- data->set.post301 = (postRedir & CURL_REDIR_POST_301)?TRUE:FALSE;
- data->set.post302 = (postRedir & CURL_REDIR_POST_302)?TRUE:FALSE;
+ data->set.keep_post = postRedir & CURL_REDIR_POST_ALL;
}
break;
diff --git a/lib/urldata.h b/lib/urldata.h
index b27fc6bf7..3474431cb 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1368,9 +1368,9 @@ struct UserDefined {
long followlocation; /* as in HTTP Location: */
long maxredirs; /* maximum no. of http(s) redirects to follow, set to -1
for infinity */
- bool post301; /* Obey RFC 2616/10.3.2 and keep POSTs as POSTs after a
- 301 */
- bool post302; /* keep POSTs as POSTs after a 302 */
+
+ int keep_post; /* keep POSTs as POSTs after a 30x request; each
+ bit represents a request, from 301 to 303 */
bool free_referer; /* set TRUE if 'referer' points to a string we
allocated */
void *postfields; /* if POST, set the fields' values here */