bettersupport for HTTP return codes 300-399
This commit is contained in:
parent
7fca24b14b
commit
c69c79dd04
@ -725,13 +725,48 @@ CURLcode curl_transfer(CURL *curl)
|
|||||||
data->newurl = NULL; /* don't show! */
|
data->newurl = NULL; /* don't show! */
|
||||||
data->bits.urlstringalloc = TRUE; /* the URL is allocated */
|
data->bits.urlstringalloc = TRUE; /* the URL is allocated */
|
||||||
|
|
||||||
/* Disable both types of POSTs, since doing a second POST when
|
|
||||||
following isn't what anyone would want! */
|
|
||||||
data->bits.http_post = FALSE;
|
|
||||||
data->bits.http_formpost = FALSE;
|
|
||||||
|
|
||||||
infof(data, "Follows Location: to new URL: '%s'\n", data->url);
|
infof(data, "Follows Location: to new URL: '%s'\n", data->url);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We get here when the HTTP code is 300-399. We need to perform
|
||||||
|
* differently based on exactly what return code there was.
|
||||||
|
* Discussed on the curl mailing list and posted about on the 26th
|
||||||
|
* of January 2001.
|
||||||
|
*/
|
||||||
|
switch(data->progress.httpcode) {
|
||||||
|
case 300: /* Multiple Choices */
|
||||||
|
case 301: /* Moved Permanently */
|
||||||
|
case 302: /* Found */
|
||||||
|
case 306: /* Not used */
|
||||||
|
case 307: /* Temporary Redirect */
|
||||||
|
default: /* for all unknown ones */
|
||||||
|
/* These are explicitly mention since I've checked RFC2616 and they
|
||||||
|
* seem to be OK to POST to.
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
case 303: /* See Other */
|
||||||
|
/* Disable both types of POSTs, since doing a second POST when
|
||||||
|
* following isn't what anyone would want! */
|
||||||
|
data->bits.http_post = FALSE;
|
||||||
|
data->bits.http_formpost = FALSE;
|
||||||
|
data->httpreq = HTTPREQ_GET; /* enfore GET request */
|
||||||
|
infof(data, "Disables POST\n");
|
||||||
|
break;
|
||||||
|
case 304: /* Not Modified */
|
||||||
|
/* 304 means we did a conditional request and it was "Not modified".
|
||||||
|
* We shouldn't get any Location: header in this response!
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
case 305: /* Use Proxy */
|
||||||
|
/* (quote from RFC2616, section 10.3.6):
|
||||||
|
* "The requested resource MUST be accessed through the proxy given
|
||||||
|
* by the Location field. The Location field gives the URI of the
|
||||||
|
* proxy. The recipient is expected to repeat this single request
|
||||||
|
* via the proxy. 305 responses MUST only be generated by origin
|
||||||
|
* servers."
|
||||||
|
*/
|
||||||
|
break;
|
||||||
|
}
|
||||||
curl_disconnect(c_connect);
|
curl_disconnect(c_connect);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user