- 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.
This commit is contained in:
Daniel Stenberg
2008-09-05 16:13:20 +00:00
parent 4c9768565e
commit 18110b519c
10 changed files with 161 additions and 22 deletions

View File

@@ -1028,12 +1028,21 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option,
data->set.maxredirs = va_arg(param, long);
break;
case CURLOPT_POST301:
case CURLOPT_POSTREDIR:
{
/*
* Obey RFC 2616/10.3.2 and resubmit a POST as a POST after a 301.
* Set the behaviour of POST when redirecting
* 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
* other - POST is kept as POST after 301 and 302
*/
data->set.post301 = (bool)(0 != va_arg(param, long));
break;
long postRedir = va_arg(param, long);
data->set.post301 = (postRedir & CURL_REDIR_POST_301)?1:0;
data->set.post302 = (postRedir & CURL_REDIR_POST_302)?1:0;
}
break;
case CURLOPT_POST:
/* Does this option serve a purpose anymore? Yes it does, when
@@ -2200,13 +2209,13 @@ CURLcode Curl_disconnect(struct connectdata *conn)
if (has_host_ntlm) {
data->state.authhost.done = FALSE;
data->state.authhost.picked =
data->state.authhost.want;
data->state.authhost.want;
}
if (has_proxy_ntlm) {
data->state.authproxy.done = FALSE;
data->state.authproxy.picked =
data->state.authproxy.want;
data->state.authproxy.want;
}
if (has_host_ntlm || has_proxy_ntlm) {