mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
James Griffiths' max-redirs fix
This commit is contained in:
parent
d4cd079b9c
commit
b8f7d94ef1
@ -624,11 +624,17 @@ CURLcode curl_transfer(CURL *curl)
|
|||||||
|
|
||||||
if((res == CURLE_OK) && data->newurl) {
|
if((res == CURLE_OK) && data->newurl) {
|
||||||
/* Location: redirect
|
/* Location: redirect
|
||||||
|
|
||||||
This is assumed to happen for HTTP(S) only!
|
This is assumed to happen for HTTP(S) only!
|
||||||
*/
|
*/
|
||||||
char prot[16];
|
char prot[16];
|
||||||
char path[URL_MAX_LENGTH];
|
char path[URL_MAX_LENGTH];
|
||||||
|
if (data->maxredirs && (data->followlocation >= data->maxredirs)) {
|
||||||
|
failf(data,"Maximum (%d) redirects followed", data->maxredirs);
|
||||||
|
curl_disconnect(c_connect);
|
||||||
|
res=CURLE_TOO_MANY_REDIRECTS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* mark the next request as a followed location: */
|
/* mark the next request as a followed location: */
|
||||||
data->bits.this_is_a_follow = TRUE;
|
data->bits.this_is_a_follow = TRUE;
|
||||||
|
@ -478,6 +478,9 @@ CURLcode curl_setopt(CURL *curl, CURLoption option, ...)
|
|||||||
case CURLOPT_TIMEOUT:
|
case CURLOPT_TIMEOUT:
|
||||||
data->timeout = va_arg(param, long);
|
data->timeout = va_arg(param, long);
|
||||||
break;
|
break;
|
||||||
|
case CURLOPT_MAXREDIRS:
|
||||||
|
data->maxredirs = va_arg(param, long);
|
||||||
|
break;
|
||||||
case CURLOPT_USERAGENT:
|
case CURLOPT_USERAGENT:
|
||||||
data->useragent = va_arg(param, char *);
|
data->useragent = va_arg(param, char *);
|
||||||
break;
|
break;
|
||||||
|
@ -417,6 +417,7 @@ struct UrlData {
|
|||||||
/* stuff related to HTTP */
|
/* stuff related to HTTP */
|
||||||
|
|
||||||
long followlocation;
|
long followlocation;
|
||||||
|
long maxredirs; /* maximum no. of http(s) redirects to follow */
|
||||||
char *referer;
|
char *referer;
|
||||||
bool free_referer; /* set TRUE if 'referer' points to a string we
|
bool free_referer; /* set TRUE if 'referer' points to a string we
|
||||||
allocated */
|
allocated */
|
||||||
|
Loading…
Reference in New Issue
Block a user