From 966fa848a0213be52d3a4b3787c36ec7c5553f22 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 27 Oct 2005 22:05:38 +0000 Subject: Nis Jorgensen filed bug report #1338648 (http://curl.haxx.se/bug/view.cgi?id=1338648) which really is more of a feature request, but anyway. It pointed out that --max-redirs did not allow it to be set to 0, which then would return an error code on the first Location: found. Based on Nis' patch, now libcurl supports CURLOPT_MAXREDIRS set to 0, or -1 for infinity. Added test case 274 to verify. --- lib/transfer.c | 2 +- lib/url.c | 2 +- lib/urldata.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/transfer.c b/lib/transfer.c index 13f31e9bc..1706ccb6f 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -1765,7 +1765,7 @@ CURLcode Curl_follow(struct SessionHandle *data, size_t newlen; char *newest; - if (data->set.maxredirs && + if ((data->set.maxredirs != -1) && (data->set.followlocation >= data->set.maxredirs)) { failf(data,"Maximum (%d) redirects followed", data->set.maxredirs); return CURLE_TOO_MANY_REDIRECTS; diff --git a/lib/url.c b/lib/url.c index c4f3fbf3d..bff500f57 100644 --- a/lib/url.c +++ b/lib/url.c @@ -320,7 +320,7 @@ CURLcode Curl_open(struct SessionHandle **curl) data->set.infilesize = -1; /* we don't know any size */ data->set.postfieldsize = -1; - + data->set.maxredirs = -1; /* allow any amount by default */ data->state.current_speed = -1; /* init to negative == impossible */ data->set.httpreq = HTTPREQ_GET; /* Default HTTP request */ diff --git a/lib/urldata.h b/lib/urldata.h index 87a751f6f..b5b2d8040 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -956,7 +956,8 @@ struct UserDefined { char *set_range; /* range, if used. See README for detailed specification on this syntax. */ long followlocation; /* as in HTTP Location: */ - long maxredirs; /* maximum no. of http(s) redirects to follow */ + long maxredirs; /* maximum no. of http(s) redirects to follow, set to -1 + for infinity */ char *set_referer; /* custom string */ bool free_referer; /* set TRUE if 'referer' points to a string we allocated */ -- cgit v1.2.3