Allow cookies when allowing redirects (next to when sending a Cookie ourselves).
This commit is contained in:
@@ -1344,11 +1344,22 @@ void BufferedCurlEasyRequest::prepRequest(AICurlEasyRequest_wat& curl_easy_reque
|
|||||||
curl_easy_request_w->setReadCallback(&curlReadCallback, lockobj);
|
curl_easy_request_w->setReadCallback(&curlReadCallback, lockobj);
|
||||||
curl_easy_request_w->setHeaderCallback(&curlHeaderCallback, lockobj);
|
curl_easy_request_w->setHeaderCallback(&curlHeaderCallback, lockobj);
|
||||||
|
|
||||||
|
bool allow_cookies = headers.hasHeader("Cookie");
|
||||||
// Allow up to ten redirects.
|
// Allow up to ten redirects.
|
||||||
if (responder->followRedir())
|
if (responder->followRedir())
|
||||||
{
|
{
|
||||||
curl_easy_request_w->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
curl_easy_request_w->setopt(CURLOPT_FOLLOWLOCATION, 1);
|
||||||
curl_easy_request_w->setopt(CURLOPT_MAXREDIRS, HTTP_REDIRECTS_DEFAULT);
|
curl_easy_request_w->setopt(CURLOPT_MAXREDIRS, HTTP_REDIRECTS_DEFAULT);
|
||||||
|
// This is needed (at least) for authentication after temporary redirection
|
||||||
|
// to id.secondlife.com for marketplace.secondlife.com.
|
||||||
|
allow_cookies = true;
|
||||||
|
}
|
||||||
|
if (allow_cookies)
|
||||||
|
{
|
||||||
|
// Given an empty or non-existing file or by passing the empty string (""),
|
||||||
|
// this option will enable cookies for this curl handle, making it understand
|
||||||
|
// and parse received cookies and then use matching cookies in future requests.
|
||||||
|
curl_easy_request_w->setopt(CURLOPT_COOKIEFILE, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep responder alive.
|
// Keep responder alive.
|
||||||
|
|||||||
@@ -85,11 +85,6 @@ LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, std::string cons
|
|||||||
|
|
||||||
void LLURLRequest::initialize_impl(void)
|
void LLURLRequest::initialize_impl(void)
|
||||||
{
|
{
|
||||||
if (mHeaders.hasHeader("Cookie"))
|
|
||||||
{
|
|
||||||
allowCookies();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the header is "Pragma" with no value, the caller intends to
|
// If the header is "Pragma" with no value, the caller intends to
|
||||||
// force libcurl to drop the Pragma header it so gratuitously inserts.
|
// force libcurl to drop the Pragma header it so gratuitously inserts.
|
||||||
// Before inserting the header, force libcurl to not use the proxy.
|
// Before inserting the header, force libcurl to not use the proxy.
|
||||||
@@ -199,12 +194,6 @@ void LLURLRequest::useProxy(const std::string &proxy)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void LLURLRequest::allowCookies()
|
|
||||||
{
|
|
||||||
AICurlEasyRequest_wat curlEasyRequest_w(*mCurlEasyRequest);
|
|
||||||
curlEasyRequest_w->setoptString(CURLOPT_COOKIEFILE, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
|
bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
|
||||||
{
|
{
|
||||||
bool rv = false;
|
bool rv = false;
|
||||||
|
|||||||
@@ -84,11 +84,6 @@ class LLURLRequest : public AICurlEasyRequestStateMachine {
|
|||||||
/*virtual*/ ~LLURLRequest() { }
|
/*virtual*/ ~LLURLRequest() { }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
* @brief Turn on cookie handling for this request with CURLOPT_COOKIEFILE.
|
|
||||||
*/
|
|
||||||
void allowCookies(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ brief Turn off (or on) the CURLOPT_PROXY header.
|
* @ brief Turn off (or on) the CURLOPT_PROXY header.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user