aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llurlrequest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage/llurlrequest.cpp')
-rw-r--r--linden/indra/llmessage/llurlrequest.cpp62
1 files changed, 23 insertions, 39 deletions
diff --git a/linden/indra/llmessage/llurlrequest.cpp b/linden/indra/llmessage/llurlrequest.cpp
index d2f854e..46e976f 100644
--- a/linden/indra/llmessage/llurlrequest.cpp
+++ b/linden/indra/llmessage/llurlrequest.cpp
@@ -19,7 +19,8 @@
19 * There are special exceptions to the terms and conditions of the GPL as 19 * There are special exceptions to the terms and conditions of the GPL as
20 * it is applied to this Source Code. View the full text of the exception 20 * it is applied to this Source Code. View the full text of the exception
21 * in the file doc/FLOSS-exception.txt in this software distribution, or 21 * in the file doc/FLOSS-exception.txt in this software distribution, or
22 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 22 * online at
23 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
23 * 24 *
24 * By copying, modifying or distributing this software, you acknowledge 25 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above, 26 * that you have read and understood your obligations described above,
@@ -43,7 +44,7 @@
43#include "llsd.h" 44#include "llsd.h"
44#include "llstring.h" 45#include "llstring.h"
45#include "apr_env.h" 46#include "apr_env.h"
46 47#include "llapr.h"
47static const U32 HTTP_STATUS_PIPE_ERROR = 499; 48static const U32 HTTP_STATUS_PIPE_ERROR = 499;
48 49
49/** 50/**
@@ -165,18 +166,16 @@ void LLURLRequest::useProxy(bool use_proxy)
165 if (use_proxy && (env_proxy == NULL)) 166 if (use_proxy && (env_proxy == NULL))
166 { 167 {
167 apr_status_t status; 168 apr_status_t status;
168 apr_pool_t* pool; 169 LLAPRPool pool;
169 apr_pool_create(&pool, NULL); 170 status = apr_env_get(&env_proxy, "ALL_PROXY", pool.getAPRPool());
170 status = apr_env_get(&env_proxy, "ALL_PROXY", pool);
171 if (status != APR_SUCCESS) 171 if (status != APR_SUCCESS)
172 { 172 {
173 status = apr_env_get(&env_proxy, "http_proxy", pool); 173 status = apr_env_get(&env_proxy, "http_proxy", pool.getAPRPool());
174 } 174 }
175 if (status != APR_SUCCESS) 175 if (status != APR_SUCCESS)
176 { 176 {
177 use_proxy = FALSE; 177 use_proxy = FALSE;
178 } 178 }
179 apr_pool_destroy(pool);
180 } 179 }
181 180
182 181
@@ -501,33 +500,25 @@ static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user)
501 std::string header(header_line, header_len); 500 std::string header(header_line, header_len);
502 501
503 // Per HTTP spec the first header line must be the status line. 502 // Per HTTP spec the first header line must be the status line.
504 if (!complete->haveHTTPStatus()) 503 if (header.substr(0,5) == "HTTP/")
505 { 504 {
506 if (header.substr(0,5) == "HTTP/") 505 std::string::iterator end = header.end();
506 std::string::iterator pos1 = std::find(header.begin(), end, ' ');
507 if (pos1 != end) ++pos1;
508 std::string::iterator pos2 = std::find(pos1, end, ' ');
509 if (pos2 != end) ++pos2;
510 std::string::iterator pos3 = std::find(pos2, end, '\r');
511
512 std::string version(header.begin(), pos1);
513 std::string status(pos1, pos2);
514 std::string reason(pos2, pos3);
515
516 S32 status_code = atoi(status.c_str());
517 if (status_code > 0)
507 { 518 {
508 std::string::iterator end = header.end(); 519 complete->httpStatus((U32)status_code, reason);
509 std::string::iterator pos1 = std::find(header.begin(), end, ' '); 520 return header_len;
510 if (pos1 != end) ++pos1;
511 std::string::iterator pos2 = std::find(pos1, end, ' ');
512 if (pos2 != end) ++pos2;
513 std::string::iterator pos3 = std::find(pos2, end, '\r');
514
515 std::string version(header.begin(), pos1);
516 std::string status(pos1, pos2);
517 std::string reason(pos2, pos3);
518
519 int statusCode = atoi(status.c_str());
520 if (statusCode >= 300 && statusCode < 400)
521 {
522 // This is a redirect, ignore it and all headers
523 // until we find a normal status code.
524 }
525 else if (statusCode > 0)
526 {
527 complete->httpStatus((U32)statusCode, reason);
528 }
529 } 521 }
530 return header_len;
531 } 522 }
532 523
533 std::string::iterator sep = std::find(header.begin(),header.end(),':'); 524 std::string::iterator sep = std::find(header.begin(),header.end(),':');
@@ -592,8 +583,7 @@ LLIOPipe::EStatus LLContextURLExtractor::process_impl(
592 * LLURLRequestComplete 583 * LLURLRequestComplete
593 */ 584 */
594LLURLRequestComplete::LLURLRequestComplete() : 585LLURLRequestComplete::LLURLRequestComplete() :
595 mRequestStatus(LLIOPipe::STATUS_ERROR), 586 mRequestStatus(LLIOPipe::STATUS_ERROR)
596 mHaveHTTPStatus(false)
597{ 587{
598 LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); 588 LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
599} 589}
@@ -610,12 +600,6 @@ void LLURLRequestComplete::header(const std::string& header, const std::string&
610} 600}
611 601
612//virtual 602//virtual
613void LLURLRequestComplete::httpStatus(U32 status, const std::string& reason)
614{
615 mHaveHTTPStatus = true;
616}
617
618//virtual
619void LLURLRequestComplete::complete(const LLChannelDescriptors& channels, 603void LLURLRequestComplete::complete(const LLChannelDescriptors& channels,
620 const buffer_ptr_t& buffer) 604 const buffer_ptr_t& buffer)
621{ 605{