diff options
author | Kartic Krishnamurthy <drunkensufi@lindenlab.com> | 2007-08-08 00:55:57 +0000 |
---|---|---|
committer | Kartic Krishnamurthy <drunkensufi@lindenlab.com> | 2007-08-08 00:55:57 +0000 |
commit | 52cb2aea8667056671b67a3c70eeefd00a061751 (patch) | |
tree | f68af9fa643127dd4c026ec5c95b41241dd279f3 /indra/llmessage | |
parent | 057a5646c14d3a61a5743e7a0cb3d6276634619e (diff) |
svn merge -r67131:67483 svn+ssh://svn/svn/linden/branches/Branch_1-18-1
Diffstat (limited to 'indra/llmessage')
-rw-r--r-- | indra/llmessage/llhttpclient.cpp | 11 | ||||
-rw-r--r-- | indra/llmessage/llurlrequest.cpp | 42 | ||||
-rw-r--r-- | indra/llmessage/llurlrequest.h | 6 |
3 files changed, 59 insertions, 0 deletions
diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp index c798e6473c..1763acaf8c 100644 --- a/indra/llmessage/llhttpclient.cpp +++ b/indra/llmessage/llhttpclient.cpp @@ -245,6 +245,7 @@ static void request( LLURLRequest *req = new LLURLRequest(method, url); req->requestEncoding(""); + // Insert custom headers is the caller sent any if (headers.isMap()) { LLSD::map_const_iterator iter = headers.beginMap(); @@ -253,7 +254,17 @@ static void request( for (; iter != end; ++iter) { std::ostringstream header; + //if the header is "Pragma" with no value + //the caller intends to force libcurl to drop + //the Pragma header it so gratuitously inserts + //Before inserting the header, force libcurl + //to not use the proxy (read: llurlrequest.cpp) + if ((iter->first == "Pragma") && (iter->second.asString() == "")) + { + req->useProxy(FALSE); + } header << iter->first << ": " << iter->second.asString() ; + llinfos << "header = " << header.str() << llendl; req->addHeader(header.str().c_str()); } } diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp index a7b8573b0d..1008f82c4d 100644 --- a/indra/llmessage/llurlrequest.cpp +++ b/indra/llmessage/llurlrequest.cpp @@ -19,6 +19,7 @@ #include "llpumpio.h" #include "llsd.h" #include "llstring.h" +#include "apr-1/apr_env.h" static const U32 HTTP_STATUS_PIPE_ERROR = 499; @@ -182,6 +183,47 @@ void LLURLRequest::setCallback(LLURLRequestComplete* callback) curl_easy_setopt(mDetail->mCurl, CURLOPT_WRITEHEADER, callback); } +// Added to mitigate the effect of libcurl looking +// for the ALL_PROXY and http_proxy env variables +// and deciding to insert a Pragma: no-cache +// header! The only usage of this method at the +// time of this writing is in llhttpclient.cpp +// in the request() method, where this method +// is called with use_proxy = FALSE +void LLURLRequest::useProxy(bool use_proxy) +{ + static char *env_proxy; + + if (use_proxy && (env_proxy == NULL)) + { + apr_status_t status; + apr_pool_t* pool; + apr_pool_create(&pool, NULL); + status = apr_env_get(&env_proxy, "ALL_PROXY", pool); + if (status != APR_SUCCESS) + { + status = apr_env_get(&env_proxy, "http_proxy", pool); + } + if (status != APR_SUCCESS) + { + use_proxy = FALSE; + } + apr_pool_destroy(pool); + } + + + lldebugs << "use_proxy = " << (use_proxy?'Y':'N') << ", env_proxy = " << env_proxy << llendl; + + if (env_proxy && use_proxy) + { + curl_easy_setopt(mDetail->mCurl, CURLOPT_PROXY, env_proxy); + } + else + { + curl_easy_setopt(mDetail->mCurl, CURLOPT_PROXY, ""); + } +} + // virtual LLIOPipe::EStatus LLURLRequest::handleError( LLIOPipe::EStatus status, diff --git a/indra/llmessage/llurlrequest.h b/indra/llmessage/llurlrequest.h index 38c801cb10..0741e557b2 100644 --- a/indra/llmessage/llurlrequest.h +++ b/indra/llmessage/llurlrequest.h @@ -154,6 +154,12 @@ public: /* @name LLIOPipe virtual implementations */ + + /** + * @ brief Turn off (or on) the CURLOPT_PROXY header. + */ + void useProxy(bool use_proxy); + public: /** * @brief Give this pipe a chance to handle a generated error |