aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/transfer.c9
-rw-r--r--lib/url.c7
-rw-r--r--lib/urldata.h1
3 files changed, 14 insertions, 3 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index d16d29268..29e53690b 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -2257,10 +2257,13 @@ CURLcode Curl_follow(struct SessionHandle *data,
* violation, many webservers expect this misbehavior. So these servers
* often answers to a POST request with an error page. To be sure that
* libcurl gets the page that most user agents would get, libcurl has to
- * force GET:
+ * force GET.
+ *
+ * This behaviour can be overriden with CURLOPT_POST301.
*/
- if( data->set.httpreq == HTTPREQ_POST
- || data->set.httpreq == HTTPREQ_POST_FORM) {
+ if( (data->set.httpreq == HTTPREQ_POST
+ || data->set.httpreq == HTTPREQ_POST_FORM)
+ && !data->set.post301) {
infof(data,
"Violate RFC 2616/10.3.2 and switch from POST to GET\n");
data->set.httpreq = HTTPREQ_GET;
diff --git a/lib/url.c b/lib/url.c
index 9a7b22a94..6735b0179 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -924,6 +924,13 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
data->set.maxredirs = va_arg(param, long);
break;
+ case CURLOPT_POST301:
+ /*
+ * Obey RFC 2616/10.3.2 and resubmit a POST as a POST after a 301.
+ */
+ data->set.post301 = (bool)(0 != va_arg(param, long));
+ break;
+
case CURLOPT_POST:
/* Does this option serve a purpose anymore? Yes it does, when
CURLOPT_POSTFIELDS isn't used and the POST data is read off the
diff --git a/lib/urldata.h b/lib/urldata.h
index 435693ee0..b1de21ac5 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -1306,6 +1306,7 @@ 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 free_referer; /* set TRUE if 'referer' points to a string we
allocated */
curl_off_t postfieldsize; /* if POST, this might have a size to use instead