aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage')
-rw-r--r--linden/indra/llmessage/llhttpclient.cpp11
-rw-r--r--linden/indra/llmessage/llurlrequest.cpp42
-rw-r--r--linden/indra/llmessage/llurlrequest.h6
3 files changed, 59 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llhttpclient.cpp b/linden/indra/llmessage/llhttpclient.cpp
index e36503a..4e844c3 100644
--- a/linden/indra/llmessage/llhttpclient.cpp
+++ b/linden/indra/llmessage/llhttpclient.cpp
@@ -265,6 +265,7 @@ static void request(
265 LLURLRequest *req = new LLURLRequest(method, url); 265 LLURLRequest *req = new LLURLRequest(method, url);
266 req->requestEncoding(""); 266 req->requestEncoding("");
267 267
268 // Insert custom headers is the caller sent any
268 if (headers.isMap()) 269 if (headers.isMap())
269 { 270 {
270 LLSD::map_const_iterator iter = headers.beginMap(); 271 LLSD::map_const_iterator iter = headers.beginMap();
@@ -273,7 +274,17 @@ static void request(
273 for (; iter != end; ++iter) 274 for (; iter != end; ++iter)
274 { 275 {
275 std::ostringstream header; 276 std::ostringstream header;
277 //if the header is "Pragma" with no value
278 //the caller intends to force libcurl to drop
279 //the Pragma header it so gratuitously inserts
280 //Before inserting the header, force libcurl
281 //to not use the proxy (read: llurlrequest.cpp)
282 if ((iter->first == "Pragma") && (iter->second.asString() == ""))
283 {
284 req->useProxy(FALSE);
285 }
276 header << iter->first << ": " << iter->second.asString() ; 286 header << iter->first << ": " << iter->second.asString() ;
287 llinfos << "header = " << header.str() << llendl;
277 req->addHeader(header.str().c_str()); 288 req->addHeader(header.str().c_str());
278 } 289 }
279 } 290 }
diff --git a/linden/indra/llmessage/llurlrequest.cpp b/linden/indra/llmessage/llurlrequest.cpp
index 1c7648b..00c0577 100644
--- a/linden/indra/llmessage/llurlrequest.cpp
+++ b/linden/indra/llmessage/llurlrequest.cpp
@@ -39,6 +39,7 @@
39#include "llpumpio.h" 39#include "llpumpio.h"
40#include "llsd.h" 40#include "llsd.h"
41#include "llstring.h" 41#include "llstring.h"
42#include "apr-1/apr_env.h"
42 43
43static const U32 HTTP_STATUS_PIPE_ERROR = 499; 44static const U32 HTTP_STATUS_PIPE_ERROR = 499;
44 45
@@ -202,6 +203,47 @@ void LLURLRequest::setCallback(LLURLRequestComplete* callback)
202 curl_easy_setopt(mDetail->mCurl, CURLOPT_WRITEHEADER, callback); 203 curl_easy_setopt(mDetail->mCurl, CURLOPT_WRITEHEADER, callback);
203} 204}
204 205
206// Added to mitigate the effect of libcurl looking
207// for the ALL_PROXY and http_proxy env variables
208// and deciding to insert a Pragma: no-cache
209// header! The only usage of this method at the
210// time of this writing is in llhttpclient.cpp
211// in the request() method, where this method
212// is called with use_proxy = FALSE
213void LLURLRequest::useProxy(bool use_proxy)
214{
215 static char *env_proxy;
216
217 if (use_proxy && (env_proxy == NULL))
218 {
219 apr_status_t status;
220 apr_pool_t* pool;
221 apr_pool_create(&pool, NULL);
222 status = apr_env_get(&env_proxy, "ALL_PROXY", pool);
223 if (status != APR_SUCCESS)
224 {
225 status = apr_env_get(&env_proxy, "http_proxy", pool);
226 }
227 if (status != APR_SUCCESS)
228 {
229 use_proxy = FALSE;
230 }
231 apr_pool_destroy(pool);
232 }
233
234
235 lldebugs << "use_proxy = " << (use_proxy?'Y':'N') << ", env_proxy = " << env_proxy << llendl;
236
237 if (env_proxy && use_proxy)
238 {
239 curl_easy_setopt(mDetail->mCurl, CURLOPT_PROXY, env_proxy);
240 }
241 else
242 {
243 curl_easy_setopt(mDetail->mCurl, CURLOPT_PROXY, "");
244 }
245}
246
205// virtual 247// virtual
206LLIOPipe::EStatus LLURLRequest::handleError( 248LLIOPipe::EStatus LLURLRequest::handleError(
207 LLIOPipe::EStatus status, 249 LLIOPipe::EStatus status,
diff --git a/linden/indra/llmessage/llurlrequest.h b/linden/indra/llmessage/llurlrequest.h
index 9088244..8aa1788 100644
--- a/linden/indra/llmessage/llurlrequest.h
+++ b/linden/indra/llmessage/llurlrequest.h
@@ -174,6 +174,12 @@ public:
174 174
175 /* @name LLIOPipe virtual implementations 175 /* @name LLIOPipe virtual implementations
176 */ 176 */
177
178 /**
179 * @ brief Turn off (or on) the CURLOPT_PROXY header.
180 */
181 void useProxy(bool use_proxy);
182
177public: 183public:
178 /** 184 /**
179 * @brief Give this pipe a chance to handle a generated error 185 * @brief Give this pipe a chance to handle a generated error