diff options
Diffstat (limited to 'indra/llmessage')
| -rwxr-xr-x | indra/llmessage/llhttpclient.cpp | 35 | ||||
| -rwxr-xr-x | indra/llmessage/llhttpclient.h | 19 | ||||
| -rwxr-xr-x | indra/llmessage/llurlrequest.cpp | 21 | ||||
| -rwxr-xr-x | indra/llmessage/llurlrequest.h | 9 | 
4 files changed, 54 insertions, 30 deletions
| diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp index 6110b035dc..11648717ad 100755 --- a/indra/llmessage/llhttpclient.cpp +++ b/indra/llmessage/llhttpclient.cpp @@ -217,7 +217,8 @@ static void request(  	Injector* body_injector,  	LLCurl::ResponderPtr responder,  	const F32 timeout = HTTP_REQUEST_EXPIRY_SECS, -	const LLSD& headers = LLSD() +	const LLSD& headers = LLSD(), +	bool follow_redirects = true      )  {  	if (!LLHTTPClient::hasPump()) @@ -231,7 +232,7 @@ static void request(  	}  	LLPumpIO::chain_t chain; -	LLURLRequest* req = new LLURLRequest(method, url); +	LLURLRequest* req = new LLURLRequest(method, url, follow_redirects);  	if(!req->isValid())//failed  	{  		if (responder) @@ -334,7 +335,8 @@ void LLHTTPClient::getByteRange(  	S32 bytes,  	ResponderPtr responder,  	const LLSD& hdrs, -	const F32 timeout) +	const F32 timeout, +	bool follow_redirects /* = true */)  {  	LLSD headers = hdrs;  	if(offset > 0 || bytes > 0) @@ -342,37 +344,42 @@ void LLHTTPClient::getByteRange(  		std::string range = llformat("bytes=%d-%d", offset, offset+bytes-1);  		headers["Range"] = range;  	} -    request(url,LLURLRequest::HTTP_GET, NULL, responder, timeout, headers); +    request(url,LLURLRequest::HTTP_GET, NULL, responder, timeout, headers, follow_redirects);  }  void LLHTTPClient::head(  	const std::string& url,  	ResponderPtr responder,  	const LLSD& headers, -	const F32 timeout) +	const F32 timeout, +	bool follow_redirects /* = true */)  { -	request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers); +	request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers, follow_redirects);  } -void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout) +void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout, +					   bool follow_redirects /* = true */)  { -	request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout, headers); +	request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout, headers, follow_redirects);  } -void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout) +void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const LLSD& headers, +								 const F32 timeout, bool follow_redirects /* = true */)  { -	request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers); +	request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers, follow_redirects);  } -void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const F32 timeout) +void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const F32 timeout, +								 bool follow_redirects /* = true */)  { -	getHeaderOnly(url, responder, LLSD(), timeout); +	getHeaderOnly(url, responder, LLSD(), timeout, follow_redirects);  } -void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const LLSD& headers, const F32 timeout) +void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const LLSD& headers, +					   const F32 timeout, bool follow_redirects /* = true */)  {  	LLURI uri;  	uri = LLURI::buildHTTP(url, LLSD::emptyArray(), query); -	get(uri.asString(), responder, headers, timeout); +	get(uri.asString(), responder, headers, timeout, follow_redirects);  }  // A simple class for managing data returned from a curl http request. diff --git a/indra/llmessage/llhttpclient.h b/indra/llmessage/llhttpclient.h index a7236ba169..5de257a4f6 100755 --- a/indra/llmessage/llhttpclient.h +++ b/indra/llmessage/llhttpclient.h @@ -63,10 +63,15 @@ public:  		const std::string& url,  		ResponderPtr,  		const LLSD& headers = LLSD(), -		const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); -	static void getByteRange(const std::string& url, S32 offset, S32 bytes, ResponderPtr, const LLSD& headers=LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); -	static void get(const std::string& url, ResponderPtr, const LLSD& headers = LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); -	static void get(const std::string& url, const LLSD& query, ResponderPtr, const LLSD& headers = LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); +		const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, +		bool follow_redirects = true); +	static void getByteRange(const std::string& url, S32 offset, S32 bytes, ResponderPtr, +							 const LLSD& headers=LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, +							 bool follow_redirects = true); +	static void get(const std::string& url, ResponderPtr, const LLSD& headers = LLSD(), +					const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, bool follow_redirects = true); +	static void get(const std::string& url, const LLSD& query, ResponderPtr, const LLSD& headers = LLSD(), +					const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, bool follow_redirects = true);  	static void put(  		const std::string& url, @@ -74,8 +79,10 @@ public:  		ResponderPtr,  		const LLSD& headers = LLSD(),  		const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); -	static void getHeaderOnly(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); -	static void getHeaderOnly(const std::string& url, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); +	static void getHeaderOnly(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, +							  bool follow_redirects = true); +	static void getHeaderOnly(const std::string& url, ResponderPtr, const LLSD& headers, +							  const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, bool follow_redirects = true);  	static void post(  		const std::string& url, diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp index de9e2fe294..683065357d 100755 --- a/indra/llmessage/llurlrequest.cpp +++ b/indra/llmessage/llurlrequest.cpp @@ -150,16 +150,19 @@ std::string LLURLRequest::actionAsVerb(LLURLRequest::ERequestAction action)  	return VERBS[action];  } -LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action) : -	mAction(action) +LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, bool follow_redirects /* = true */) : +	mAction(action), +	mFollowRedirects(follow_redirects)  {  	initialize();  }  LLURLRequest::LLURLRequest(  	LLURLRequest::ERequestAction action, -	const std::string& url) : -	mAction(action) +	const std::string& url, +	bool follow_redirects /* = true */) : +	mAction(action), +	mFollowRedirects(follow_redirects)  {  	initialize();  	setURL(url); @@ -479,12 +482,18 @@ bool LLURLRequest::configure()  	case HTTP_HEAD:  		mDetail->mCurlRequest->setopt(CURLOPT_HEADER, 1);  		mDetail->mCurlRequest->setopt(CURLOPT_NOBODY, 1); -		mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1); +		if (mFollowRedirects) +		{ +			mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1); +		}  		rv = true;  		break;  	case HTTP_GET:  		mDetail->mCurlRequest->setopt(CURLOPT_HTTPGET, 1); -		mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1); +		if (mFollowRedirects) +		{ +			mDetail->mCurlRequest->setopt(CURLOPT_FOLLOWLOCATION, 1); +		}  		// Set Accept-Encoding to allow response compression  		mDetail->mCurlRequest->setoptString(CURLOPT_ENCODING, ""); diff --git a/indra/llmessage/llurlrequest.h b/indra/llmessage/llurlrequest.h index 44d358d906..20d6e30d17 100755 --- a/indra/llmessage/llurlrequest.h +++ b/indra/llmessage/llurlrequest.h @@ -95,7 +95,7 @@ public:  	 *  	 * @param action One of the ERequestAction enumerations.  	 */ -	LLURLRequest(ERequestAction action); +	LLURLRequest(ERequestAction action, bool follow_redirects = true);  	/**   	 * @brief Constructor. @@ -103,7 +103,7 @@ public:  	 * @param action One of the ERequestAction enumerations.  	 * @param url The url of the request. It should already be encoded.  	 */ -	LLURLRequest(ERequestAction action, const std::string& url); +	LLURLRequest(ERequestAction action, const std::string& url, bool follow_redirects = true);  	/**   	 * @brief Destructor. @@ -219,10 +219,11 @@ protected:  	};  	EState mState;  	ERequestAction mAction; +	bool mFollowRedirects;  	LLURLRequestDetail* mDetail;  	LLIOPipe::ptr_t mCompletionCallback; -	 S32 mRequestTransferedBytes; -	 S32 mResponseTransferedBytes; +	S32 mRequestTransferedBytes; +	S32 mResponseTransferedBytes;  	static CURLcode _sslCtxCallback(CURL * curl, void *sslctx, void *param); | 
