Let curl follow redirects by default.

Turns out that the only responders that want to get the redirect
status codes themselves are the ones that already had a
redirect_status_ok() exception.
This commit is contained in:
Aleric Inglewood
2013-09-28 20:41:10 +02:00
parent 243b499b95
commit 1c0f87d82f
10 changed files with 15 additions and 24 deletions

View File

@@ -1262,7 +1262,8 @@ std::string CurlEasyRequest::getLowercaseHostname(void) const
//-----------------------------------------------------------------------------
// BufferedCurlEasyRequest
static int const HTTP_REDIRECTS_DEFAULT = 10;
static int const HTTP_REDIRECTS_DEFAULT = 16; // Singu note: I've seen up to 10 redirects, so setting the limit to 10 is cutting it.
// This limit is only here to avoid a redirect loop (infinite redirections).
LLChannelDescriptors const BufferedCurlEasyRequest::sChannels;
LLMutex BufferedCurlEasyRequest::sResponderCallbackMutex;
@@ -1411,8 +1412,8 @@ void BufferedCurlEasyRequest::prepRequest(AICurlEasyRequest_wat& curl_easy_reque
curl_easy_request_w->setHeaderCallback(&curlHeaderCallback, lockobj);
bool allow_cookies = headers.hasHeader("Cookie");
// Allow up to ten redirects.
if (responder->followRedir())
// Allow up to sixteen redirects.
if (!responder->pass_redirect_status())
{
curl_easy_request_w->setopt(CURLOPT_FOLLOWLOCATION, 1);
curl_easy_request_w->setopt(CURLOPT_MAXREDIRS, HTTP_REDIRECTS_DEFAULT);

View File

@@ -2062,7 +2062,7 @@ void BufferedCurlEasyRequest::setStatusAndReason(U32 status, std::string const&
// Sanity check. If the server replies with a redirect status then we better have that option turned on!
if ((status >= 300 && status < 400) && mResponder && !mResponder->redirect_status_ok())
{
llerrs << "Received " << status << " (" << reason << ") for responder \"" << mResponder->getName() << "\" which has no followRedir()!" << llendl;
llerrs << "Received " << status << " (" << reason << ") for responder \"" << mResponder->getName() << "\" which does not allow redirection!" << llendl;
}
}

View File

@@ -221,12 +221,12 @@ public:
// The default is to keep connections open for possible reuse.
virtual bool forbidReuse(void) const { return false; }
// A derived class should return true if curl should follow redirections.
// The default is not to follow redirections.
virtual bool followRedir(void) const { return false; }
// A derived class should return true if curl should not follow redirections, but instead pass redirection status codes to the responder.
// The default is to follow redirections and not pass them to the responder.
virtual bool pass_redirect_status(void) const { return false; }
// If this function returns false then we generate an error when a redirect status (300..399) is received.
virtual bool redirect_status_ok(void) const { return followRedir(); }
virtual bool redirect_status_ok(void) const { return true; }
// Returns the capability type used by this responder.
virtual AICapabilityType capability_type(void) const { return cap_other; }
@@ -259,7 +259,6 @@ public:
class ResponderHeadersOnly : public ResponderBase {
private:
/*virtual*/ bool needsHeaders(void) const { return true; }
/*virtual*/ bool followRedir(void) const { return true; }
protected:
// ResponderBase event