Manual pick of stuff from 'shycurl' (68ad5411) that seemed to make sense.

This commit is contained in:
Aleric Inglewood
2012-08-14 00:45:49 +02:00
parent 36ff4dcd11
commit 19293601b3
4 changed files with 18 additions and 27 deletions

View File

@@ -25,7 +25,6 @@
*/ */
#include "linden_common.h" #include "linden_common.h"
#include <openssl/x509_vfy.h>
#include "llhttpclient.h" #include "llhttpclient.h"
#include "llassetstorage.h" #include "llassetstorage.h"
@@ -39,7 +38,6 @@
#include "message.h" #include "message.h"
const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f; const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f;
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@@ -186,11 +184,9 @@ namespace
LLVFile vfile(gVFS, mUUID, mAssetType, LLVFile::READ); LLVFile vfile(gVFS, mUUID, mAssetType, LLVFile::READ);
S32 fileSize = vfile.getSize(); S32 fileSize = vfile.getSize();
U8* fileBuffer; std::vector<U8> fileBuffer(fileSize);
fileBuffer = new U8 [fileSize]; vfile.read(&fileBuffer[0], fileSize);
vfile.read(fileBuffer, fileSize); ostream.write((char*)&fileBuffer[0], fileSize);
ostream.write((char*)fileBuffer, fileSize);
delete [] fileBuffer;
eos = true; eos = true;
return STATUS_DONE; return STATUS_DONE;
} }
@@ -199,7 +195,6 @@ namespace
LLAssetType::EType mAssetType; LLAssetType::EType mAssetType;
}; };
LLPumpIO* theClientPump = NULL; LLPumpIO* theClientPump = NULL;
} }
@@ -209,8 +204,7 @@ static void request(
Injector* body_injector, Injector* body_injector,
LLCurl::ResponderPtr responder, LLCurl::ResponderPtr responder,
const F32 timeout = HTTP_REQUEST_EXPIRY_SECS, const F32 timeout = HTTP_REQUEST_EXPIRY_SECS,
const LLSD& headers = LLSD() const LLSD& headers = LLSD())
)
{ {
if (responder) if (responder)
{ {

View File

@@ -34,10 +34,10 @@
#include <string> #include <string>
#include <boost/intrusive_ptr.hpp> #include <boost/intrusive_ptr.hpp>
#include "llurlrequest.h"
#include "llassettype.h" #include "llassettype.h"
#include "llcurl.h" #include "llcurl.h"
#include "lliopipe.h" #include "lliopipe.h"
#include "llurlrequest.h"
extern const F32 HTTP_REQUEST_EXPIRY_SECS; extern const F32 HTTP_REQUEST_EXPIRY_SECS;

View File

@@ -36,17 +36,17 @@
#include <algorithm> #include <algorithm>
#include <openssl/x509_vfy.h> #include <openssl/x509_vfy.h>
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include "llcurl.h" #include "llcurl.h"
#include "llfasttimer.h"
#include "llioutil.h" #include "llioutil.h"
#include "llmemtype.h" #include "llmemtype.h"
#include "llproxy.h"
#include "llpumpio.h" #include "llpumpio.h"
#include "llsd.h" #include "llsd.h"
#include "llstring.h" #include "llstring.h"
#include "apr_env.h" #include "apr_env.h"
#include "llapr.h" #include "llapr.h"
#include "llscopedvolatileaprpool.h" #include "llscopedvolatileaprpool.h"
#include "llfasttimer.h"
static const U32 HTTP_STATUS_PIPE_ERROR = 499; static const U32 HTTP_STATUS_PIPE_ERROR = 499;
/** /**
@@ -73,7 +73,6 @@ public:
U32 mBodyLimit; U32 mBodyLimit;
S32 mByteAccumulator; S32 mByteAccumulator;
bool mIsBodyLimitSet; bool mIsBodyLimitSet;
LLURLRequest::SSLCertVerifyCallback mSSLVerifyCallback;
}; };
LLURLRequestDetail::LLURLRequestDetail() : LLURLRequestDetail::LLURLRequestDetail() :
@@ -81,8 +80,7 @@ LLURLRequestDetail::LLURLRequestDetail() :
mLastRead(NULL), mLastRead(NULL),
mBodyLimit(0), mBodyLimit(0),
mByteAccumulator(0), mByteAccumulator(0),
mIsBodyLimitSet(false), mIsBodyLimitSet(false)
mSSLVerifyCallback(NULL)
{ {
} }
@@ -164,11 +162,11 @@ void LLURLRequest::addHeader(const char* header)
void LLURLRequest::checkRootCertificate(bool check) void LLURLRequest::checkRootCertificate(bool check)
{ {
mDetail->mCurlRequest->setopt(CURLOPT_SSL_VERIFYPEER, (check? TRUE : FALSE)); AICurlEasyRequest_wat curlEasyRequest_w(*mDetail->mCurlEasyRequest);
mDetail->mCurlRequest->setoptString(CURLOPT_ENCODING, ""); curlEasyRequest_w->setopt(CURLOPT_SSL_VERIFYPEER, check ? 1L : 0L);
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, "");
} }
void LLURLRequest::setBodyLimit(U32 size) void LLURLRequest::setBodyLimit(U32 size)
{ {
mDetail->mBodyLimit = 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); 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) void LLURLRequest::useProxy(const std::string &proxy)
@@ -320,6 +318,8 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
//llinfos << "LLURLRequest::process_impl()" << llendl; //llinfos << "LLURLRequest::process_impl()" << llendl;
if (!buffer) return STATUS_ERROR; 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 // we're still waiting or processing, check how many
// bytes we have accumulated. // bytes we have accumulated.
const S32 MIN_ACCUMULATION = 100000; const S32 MIN_ACCUMULATION = 100000;

View File

@@ -40,7 +40,6 @@
#include "llerror.h" #include "llerror.h"
#include "llcurl.h" #include "llcurl.h"
extern const std::string CONTEXT_REQUEST; extern const std::string CONTEXT_REQUEST;
extern const std::string CONTEXT_RESPONSE; extern const std::string CONTEXT_RESPONSE;
extern const std::string CONTEXT_TRANSFERED_BYTES; extern const std::string CONTEXT_TRANSFERED_BYTES;
@@ -144,7 +143,6 @@ public:
*/ */
void checkRootCertificate(bool check); void checkRootCertificate(bool check);
/** /**
* @brief Return at most size bytes of body. * @brief Return at most size bytes of body.
* *
@@ -198,7 +196,6 @@ public:
*/ */
virtual EStatus handleError(EStatus status, LLPumpIO* pump); virtual EStatus handleError(EStatus status, LLPumpIO* pump);
protected: protected:
/** /**
* @brief Process the data in buffer * @brief Process the data in buffer
@@ -224,8 +221,8 @@ protected:
ERequestAction mAction; ERequestAction mAction;
LLURLRequestDetail* mDetail; LLURLRequestDetail* mDetail;
LLIOPipe::ptr_t mCompletionCallback; LLIOPipe::ptr_t mCompletionCallback;
S32 mRequestTransferedBytes; S32 mRequestTransferedBytes;
S32 mResponseTransferedBytes; S32 mResponseTransferedBytes;
// mRemoved is used instead of changing mState directly, because I'm not convinced the latter is atomic. // 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. // Set to false before adding curl request and then only tested.