From 19293601b32bd5b2499c12daab280856664c4f8c Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Tue, 14 Aug 2012 00:45:49 +0200 Subject: [PATCH] Manual pick of stuff from 'shycurl' (68ad5411) that seemed to make sense. --- indra/llmessage/llhttpclient.cpp | 14 ++++---------- indra/llmessage/llhttpclient.h | 2 +- indra/llmessage/llurlrequest.cpp | 22 +++++++++++----------- indra/llmessage/llurlrequest.h | 7 ++----- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp index d611a6b5f..c04bad5e4 100644 --- a/indra/llmessage/llhttpclient.cpp +++ b/indra/llmessage/llhttpclient.cpp @@ -25,7 +25,6 @@ */ #include "linden_common.h" -#include #include "llhttpclient.h" #include "llassetstorage.h" @@ -39,7 +38,6 @@ #include "message.h" - const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f; //////////////////////////////////////////////////////////////////////////// @@ -186,11 +184,9 @@ namespace LLVFile vfile(gVFS, mUUID, mAssetType, LLVFile::READ); S32 fileSize = vfile.getSize(); - U8* fileBuffer; - fileBuffer = new U8 [fileSize]; - vfile.read(fileBuffer, fileSize); - ostream.write((char*)fileBuffer, fileSize); - delete [] fileBuffer; + std::vector fileBuffer(fileSize); + vfile.read(&fileBuffer[0], fileSize); + ostream.write((char*)&fileBuffer[0], fileSize); eos = true; return STATUS_DONE; } @@ -199,7 +195,6 @@ namespace LLAssetType::EType mAssetType; }; - LLPumpIO* theClientPump = NULL; } @@ -209,8 +204,7 @@ static void request( Injector* body_injector, LLCurl::ResponderPtr responder, const F32 timeout = HTTP_REQUEST_EXPIRY_SECS, - const LLSD& headers = LLSD() - ) + const LLSD& headers = LLSD()) { if (responder) { diff --git a/indra/llmessage/llhttpclient.h b/indra/llmessage/llhttpclient.h index d371290db..ae22fd30a 100644 --- a/indra/llmessage/llhttpclient.h +++ b/indra/llmessage/llhttpclient.h @@ -34,10 +34,10 @@ #include #include -#include "llurlrequest.h" #include "llassettype.h" #include "llcurl.h" #include "lliopipe.h" +#include "llurlrequest.h" extern const F32 HTTP_REQUEST_EXPIRY_SECS; diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp index ba0d24ce3..4948f10d6 100644 --- a/indra/llmessage/llurlrequest.cpp +++ b/indra/llmessage/llurlrequest.cpp @@ -36,17 +36,17 @@ #include #include #include + #include "llcurl.h" -#include "llfasttimer.h" #include "llioutil.h" #include "llmemtype.h" -#include "llproxy.h" #include "llpumpio.h" #include "llsd.h" #include "llstring.h" #include "apr_env.h" #include "llapr.h" #include "llscopedvolatileaprpool.h" +#include "llfasttimer.h" static const U32 HTTP_STATUS_PIPE_ERROR = 499; /** @@ -73,7 +73,6 @@ public: U32 mBodyLimit; S32 mByteAccumulator; bool mIsBodyLimitSet; - LLURLRequest::SSLCertVerifyCallback mSSLVerifyCallback; }; LLURLRequestDetail::LLURLRequestDetail() : @@ -81,8 +80,7 @@ LLURLRequestDetail::LLURLRequestDetail() : mLastRead(NULL), mBodyLimit(0), mByteAccumulator(0), - mIsBodyLimitSet(false), - mSSLVerifyCallback(NULL) + mIsBodyLimitSet(false) { } @@ -164,11 +162,11 @@ void LLURLRequest::addHeader(const char* header) void LLURLRequest::checkRootCertificate(bool check) { - mDetail->mCurlRequest->setopt(CURLOPT_SSL_VERIFYPEER, (check? TRUE : FALSE)); - mDetail->mCurlRequest->setoptString(CURLOPT_ENCODING, ""); + AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest); + curlEasyRequest_w->setopt(CURLOPT_SSL_VERIFYPEER, check ? 1L : 0L); + curlEasyRequest_w->setoptString(CURLOPT_ENCODING, ""); } - void LLURLRequest::setBodyLimit(U32 size) { mDetail->mBodyLimit = size; @@ -214,10 +212,10 @@ void LLURLRequest::useProxy(bool use_proxy) } } - lldebugs << "use_proxy = " << (use_proxy?'Y':'N') << ", env_proxy = \"" << env_proxy << "\"" << llendl; + LL_DEBUGS("Proxy") << "use_proxy = " << (use_proxy?'Y':'N') << ", env_proxy = " << (!env_proxy.empty() ? env_proxy : "(null)") << LL_ENDL; AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest); - curlEasyRequest_w->setoptString(CURLOPT_PROXY, use_proxy ? env_proxy : std::string("")); + curlEasyRequest_w->setoptString(CURLOPT_PROXY, (use_proxy && !env_proxy.empty()) ? env_proxy : std::string("")); } void LLURLRequest::useProxy(const std::string &proxy) @@ -319,7 +317,9 @@ LLIOPipe::EStatus LLURLRequest::process_impl( LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); //llinfos << "LLURLRequest::process_impl()" << llendl; if (!buffer) return STATUS_ERROR; - + + if (!mDetail) return STATUS_ERROR; //Seems to happen on occasion. Need to hunt down why. + // we're still waiting or processing, check how many // bytes we have accumulated. const S32 MIN_ACCUMULATION = 100000; diff --git a/indra/llmessage/llurlrequest.h b/indra/llmessage/llurlrequest.h index 10ad50f28..fdf7d873e 100644 --- a/indra/llmessage/llurlrequest.h +++ b/indra/llmessage/llurlrequest.h @@ -40,7 +40,6 @@ #include "llerror.h" #include "llcurl.h" - extern const std::string CONTEXT_REQUEST; extern const std::string CONTEXT_RESPONSE; extern const std::string CONTEXT_TRANSFERED_BYTES; @@ -144,7 +143,6 @@ public: */ void checkRootCertificate(bool check); - /** * @brief Return at most size bytes of body. * @@ -197,7 +195,6 @@ public: * @brief Give this pipe a chance to handle a generated error */ virtual EStatus handleError(EStatus status, LLPumpIO* pump); - protected: /** @@ -224,8 +221,8 @@ protected: ERequestAction mAction; LLURLRequestDetail* mDetail; LLIOPipe::ptr_t mCompletionCallback; - S32 mRequestTransferedBytes; - S32 mResponseTransferedBytes; + S32 mRequestTransferedBytes; + S32 mResponseTransferedBytes; // mRemoved is used instead of changing mState directly, because I'm not convinced the latter is atomic. // Set to false before adding curl request and then only tested.