Merge remote-tracking branch 'aleric/breakforce' into breakforce
This commit is contained in:
@@ -200,15 +200,15 @@ static bool need_renegotiation_hack = false;
|
|||||||
void ssl_init(void)
|
void ssl_init(void)
|
||||||
{
|
{
|
||||||
// The version identifier format is: MMNNFFPPS: major minor fix patch status.
|
// The version identifier format is: MMNNFFPPS: major minor fix patch status.
|
||||||
int const compiled_openSLL_major = (OPENSSL_VERSION_NUMBER >> 28) & 0xff;
|
int const compiled_openSSL_major = (OPENSSL_VERSION_NUMBER >> 28) & 0xff;
|
||||||
int const compiled_openSLL_minor = (OPENSSL_VERSION_NUMBER >> 20) & 0xff;
|
int const compiled_openSSL_minor = (OPENSSL_VERSION_NUMBER >> 20) & 0xff;
|
||||||
unsigned long const ssleay = SSLeay();
|
unsigned long const ssleay = SSLeay();
|
||||||
int const linked_openSLL_major = (ssleay >> 28) & 0xff;
|
int const linked_openSSL_major = (ssleay >> 28) & 0xff;
|
||||||
int const linked_openSLL_minor = (ssleay >> 20) & 0xff;
|
int const linked_openSSL_minor = (ssleay >> 20) & 0xff;
|
||||||
// Check if dynamically loaded version is compatible with the one we compiled against.
|
// Check if dynamically loaded version is compatible with the one we compiled against.
|
||||||
// As off version 1.0.0 also minor versions are compatible.
|
// As off version 1.0.0 also minor versions are compatible.
|
||||||
if (linked_openSLL_major != compiled_openSLL_major ||
|
if (linked_openSSL_major != compiled_openSSL_major ||
|
||||||
(compiled_openSLL_major == 0 && linked_openSLL_minor != compiled_openSLL_minor))
|
(linked_openSSL_major == 0 && linked_openSSL_minor != compiled_openSSL_minor))
|
||||||
{
|
{
|
||||||
llerrs << "The viewer was compiled against " << OPENSSL_VERSION_TEXT <<
|
llerrs << "The viewer was compiled against " << OPENSSL_VERSION_TEXT <<
|
||||||
" but linked against " << SSLeay_version(SSLEAY_VERSION) <<
|
" but linked against " << SSLeay_version(SSLEAY_VERSION) <<
|
||||||
@@ -949,7 +949,7 @@ static int curl_debug_cb(CURL*, curl_infotype infotype, char* buf, size_t size,
|
|||||||
{
|
{
|
||||||
LibcwDoutStream << size << " bytes";
|
LibcwDoutStream << size << " bytes";
|
||||||
bool finished = false;
|
bool finished = false;
|
||||||
int i = 0;
|
size_t i = 0;
|
||||||
while (i < size)
|
while (i < size)
|
||||||
{
|
{
|
||||||
char c = buf[i];
|
char c = buf[i];
|
||||||
@@ -1191,9 +1191,7 @@ void CurlResponderBuffer::resetState(AICurlEasyRequest_wat& curl_easy_request_w)
|
|||||||
curl_easy_request_w->resetState();
|
curl_easy_request_w->resetState();
|
||||||
|
|
||||||
mOutput.reset();
|
mOutput.reset();
|
||||||
|
mInput.reset();
|
||||||
mInput.str("");
|
|
||||||
mInput.clear();
|
|
||||||
|
|
||||||
mHeaderOutput.str("");
|
mHeaderOutput.str("");
|
||||||
mHeaderOutput.clear();
|
mHeaderOutput.clear();
|
||||||
@@ -1211,6 +1209,10 @@ void CurlResponderBuffer::prepRequest(AICurlEasyRequest_wat& curl_easy_request_w
|
|||||||
curl_easy_request_w->setoptString(CURLOPT_ENCODING, "");
|
curl_easy_request_w->setoptString(CURLOPT_ENCODING, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mInput.reset(new LLBufferArray);
|
||||||
|
mInput->setThreaded(true);
|
||||||
|
mLastRead = NULL;
|
||||||
|
|
||||||
mOutput.reset(new LLBufferArray);
|
mOutput.reset(new LLBufferArray);
|
||||||
mOutput->setThreaded(true);
|
mOutput->setThreaded(true);
|
||||||
|
|
||||||
@@ -1271,16 +1273,10 @@ size_t CurlResponderBuffer::curlReadCallback(char* data, size_t size, size_t nme
|
|||||||
// to make sure that callbacks and destruction aren't done simultaneously.
|
// to make sure that callbacks and destruction aren't done simultaneously.
|
||||||
AICurlEasyRequest_wat buffered_easy_request_w(*lockobj);
|
AICurlEasyRequest_wat buffered_easy_request_w(*lockobj);
|
||||||
|
|
||||||
|
S32 bytes = size * nmemb; // The maximum amount to read.
|
||||||
AICurlResponderBuffer_wat buffer_w(*lockobj);
|
AICurlResponderBuffer_wat buffer_w(*lockobj);
|
||||||
S32 n = size * nmemb;
|
buffer_w->mLastRead = buffer_w->getInput()->readAfter(sChannels.out(), buffer_w->mLastRead, (U8*)data, bytes);
|
||||||
S32 startpos = buffer_w->getInput().tellg();
|
return bytes; // Return the amount actually read.
|
||||||
buffer_w->getInput().seekg(0, std::ios::end);
|
|
||||||
S32 endpos = buffer_w->getInput().tellg();
|
|
||||||
buffer_w->getInput().seekg(startpos, std::ios::beg);
|
|
||||||
S32 maxn = endpos - startpos;
|
|
||||||
n = llmin(n, maxn);
|
|
||||||
buffer_w->getInput().read(data, n);
|
|
||||||
return n;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
|
|||||||
@@ -291,9 +291,9 @@ class CurlResponderBuffer : protected AICurlEasyHandleEvents {
|
|||||||
void resetState(AICurlEasyRequest_wat& curl_easy_request_w);
|
void resetState(AICurlEasyRequest_wat& curl_easy_request_w);
|
||||||
void prepRequest(AICurlEasyRequest_wat& buffered_curl_easy_request_w, std::vector<std::string> const& headers, AICurlInterface::ResponderPtr responder, S32 time_out = 0, bool post = false);
|
void prepRequest(AICurlEasyRequest_wat& buffered_curl_easy_request_w, std::vector<std::string> const& headers, AICurlInterface::ResponderPtr responder, S32 time_out = 0, bool post = false);
|
||||||
|
|
||||||
std::stringstream& getInput() { return mInput; }
|
LLIOPipe::buffer_ptr_t& getInput(void) { return mInput; }
|
||||||
std::stringstream& getHeaderOutput() { return mHeaderOutput; }
|
std::stringstream& getHeaderOutput(void) { return mHeaderOutput; }
|
||||||
LLIOPipe::buffer_ptr_t& getOutput() { return mOutput; }
|
LLIOPipe::buffer_ptr_t& getOutput(void) { return mOutput; }
|
||||||
|
|
||||||
// Called if libcurl doesn't deliver within CurlRequestTimeOut seconds.
|
// Called if libcurl doesn't deliver within CurlRequestTimeOut seconds.
|
||||||
void timed_out(void);
|
void timed_out(void);
|
||||||
@@ -307,13 +307,14 @@ class CurlResponderBuffer : protected AICurlEasyHandleEvents {
|
|||||||
/*virtual*/ void removed_from_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w);
|
/*virtual*/ void removed_from_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::stringstream mInput;
|
LLIOPipe::buffer_ptr_t mInput;
|
||||||
|
U8* mLastRead; // Pointer into mInput where we last stopped reading (or NULL to start at the beginning).
|
||||||
std::stringstream mHeaderOutput;
|
std::stringstream mHeaderOutput;
|
||||||
LLIOPipe::buffer_ptr_t mOutput;
|
LLIOPipe::buffer_ptr_t mOutput;
|
||||||
AICurlInterface::ResponderPtr mResponder;
|
AICurlInterface::ResponderPtr mResponder;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static LLChannelDescriptors const sChannels; // Channel object for mOutput: we ONLY use channel 0, so this can be a constant.
|
static LLChannelDescriptors const sChannels; // Channel object for mInput (channel out()) and mOutput (channel in()).
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// This class may only be created by constructing a ThreadSafeBufferedCurlEasyRequest.
|
// This class may only be created by constructing a ThreadSafeBufferedCurlEasyRequest.
|
||||||
|
|||||||
@@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
#include "llsdserialize.h"
|
#include "llsdserialize.h"
|
||||||
#include "llcurlrequest.h"
|
#include "llcurlrequest.h"
|
||||||
|
#include "llbuffer.h"
|
||||||
|
#include "llbufferstream.h"
|
||||||
#include "statemachine/aicurleasyrequeststatemachine.h"
|
#include "statemachine/aicurleasyrequeststatemachine.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -94,8 +96,11 @@ bool Request::post(std::string const& url, headers_t const& headers, std::string
|
|||||||
|
|
||||||
buffer_w->prepRequest(buffered_easy_request_w, headers, responder);
|
buffer_w->prepRequest(buffered_easy_request_w, headers, responder);
|
||||||
|
|
||||||
buffer_w->getInput().write(data.data(), data.size());
|
U32 bytes = data.size();
|
||||||
S32 bytes = buffer_w->getInput().str().length();
|
bool success = buffer_w->getInput()->append(buffer_w->sChannels.out(), (U8 const*)data.data(), bytes);
|
||||||
|
llassert_always(success); // AIFIXME: Maybe throw an error.
|
||||||
|
if (!success)
|
||||||
|
return false;
|
||||||
buffered_easy_request_w->setPost(NULL, bytes);
|
buffered_easy_request_w->setPost(NULL, bytes);
|
||||||
buffered_easy_request_w->addHeader("Content-Type: application/octet-stream");
|
buffered_easy_request_w->addHeader("Content-Type: application/octet-stream");
|
||||||
buffered_easy_request_w->finalizeRequest(url);
|
buffered_easy_request_w->finalizeRequest(url);
|
||||||
@@ -121,8 +126,9 @@ bool Request::post(std::string const& url, headers_t const& headers, LLSD const&
|
|||||||
|
|
||||||
buffer_w->prepRequest(buffered_easy_request_w, headers, responder);
|
buffer_w->prepRequest(buffered_easy_request_w, headers, responder);
|
||||||
|
|
||||||
LLSDSerialize::toXML(data, buffer_w->getInput());
|
LLBufferStream buffer_stream(buffer_w->sChannels, buffer_w->getInput().get());
|
||||||
S32 bytes = buffer_w->getInput().str().length();
|
LLSDSerialize::toXML(data, buffer_stream);
|
||||||
|
S32 bytes = buffer_w->getInput()->countAfter(buffer_w->sChannels.out(), NULL);
|
||||||
buffered_easy_request_w->setPost(NULL, bytes);
|
buffered_easy_request_w->setPost(NULL, bytes);
|
||||||
buffered_easy_request_w->addHeader("Content-Type: application/llsd+xml");
|
buffered_easy_request_w->addHeader("Content-Type: application/llsd+xml");
|
||||||
buffered_easy_request_w->finalizeRequest(url);
|
buffered_easy_request_w->finalizeRequest(url);
|
||||||
|
|||||||
Reference in New Issue
Block a user