summaryrefslogtreecommitdiff
path: root/indra/llmessage/llcurl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llcurl.cpp')
-rw-r--r--indra/llmessage/llcurl.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 5ff41322b7..dc02367a62 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -229,7 +229,7 @@ public:
U32 report(CURLcode);
void getTransferInfo(LLCurl::TransferInfo* info);
- void prepRequest(const std::string& url, ResponderPtr, bool post = false);
+ void prepRequest(const std::string& url, const std::vector<std::string>& headers, ResponderPtr, bool post = false);
const char* getErrorBuffer();
@@ -441,7 +441,9 @@ size_t curlHeaderCallback(void* data, size_t size, size_t nmemb, void* user_data
return n;
}
-void LLCurl::Easy::prepRequest(const std::string& url, ResponderPtr responder, bool post)
+void LLCurl::Easy::prepRequest(const std::string& url,
+ const std::vector<std::string>& headers,
+ ResponderPtr responder, bool post)
{
resetState();
@@ -474,8 +476,13 @@ void LLCurl::Easy::prepRequest(const std::string& url, ResponderPtr responder, b
{
slist_append("Connection: keep-alive");
slist_append("Keep-alive: 300");
+ // Accept and other headers
+ for (std::vector<std::string>::const_iterator iter = headers.begin();
+ iter != headers.end(); ++iter)
+ {
+ slist_append((*iter).c_str());
+ }
}
- // *FIX: should have ACCEPT headers
}
////////////////////////////////////////////////////////////////////////////
@@ -685,15 +692,18 @@ LLCurlRequest::LLCurlRequest() :
mActiveMulti(NULL),
mActiveRequestCount(0)
{
+ mThreadID = LLThread::currentID();
}
LLCurlRequest::~LLCurlRequest()
{
+ llassert_always(mThreadID == LLThread::currentID());
for_each(mMultiSet.begin(), mMultiSet.end(), DeletePointer());
}
void LLCurlRequest::addMulti()
{
+ llassert_always(mThreadID == LLThread::currentID());
LLCurl::Multi* multi = new LLCurl::Multi();
mMultiSet.insert(multi);
mActiveMulti = multi;
@@ -723,17 +733,20 @@ bool LLCurlRequest::addEasy(LLCurl::Easy* easy)
void LLCurlRequest::get(const std::string& url, LLCurl::ResponderPtr responder)
{
- getByteRange(url, 0, -1, responder);
+ getByteRange(url, headers_t(), 0, -1, responder);
}
-bool LLCurlRequest::getByteRange(const std::string& url, S32 offset, S32 length, LLCurl::ResponderPtr responder)
+bool LLCurlRequest::getByteRange(const std::string& url,
+ const headers_t& headers,
+ S32 offset, S32 length,
+ LLCurl::ResponderPtr responder)
{
LLCurl::Easy* easy = allocEasy();
if (!easy)
{
return false;
}
- easy->prepRequest(url, responder);
+ easy->prepRequest(url, headers, responder);
easy->setopt(CURLOPT_HTTPGET, 1);
if (length > 0)
{
@@ -745,14 +758,17 @@ bool LLCurlRequest::getByteRange(const std::string& url, S32 offset, S32 length,
return res;
}
-bool LLCurlRequest::post(const std::string& url, const LLSD& data, LLCurl::ResponderPtr responder)
+bool LLCurlRequest::post(const std::string& url,
+ const headers_t& headers,
+ const LLSD& data,
+ LLCurl::ResponderPtr responder)
{
LLCurl::Easy* easy = allocEasy();
if (!easy)
{
return false;
}
- easy->prepRequest(url, responder);
+ easy->prepRequest(url, headers, responder);
LLSDSerialize::toXML(data, easy->getInput());
S32 bytes = easy->getInput().str().length();
@@ -772,6 +788,7 @@ bool LLCurlRequest::post(const std::string& url, const LLSD& data, LLCurl::Respo
// Note: call once per frame
S32 LLCurlRequest::process()
{
+ llassert_always(mThreadID == LLThread::currentID());
S32 res = 0;
for (curlmulti_set_t::iterator iter = mMultiSet.begin();
iter != mMultiSet.end(); )
@@ -791,6 +808,7 @@ S32 LLCurlRequest::process()
S32 LLCurlRequest::getQueued()
{
+ llassert_always(mThreadID == LLThread::currentID());
S32 queued = 0;
for (curlmulti_set_t::iterator iter = mMultiSet.begin();
iter != mMultiSet.end(); )
@@ -1011,7 +1029,7 @@ void LLCurl::initClass()
S32 mutex_count = CRYPTO_num_locks();
for (S32 i=0; i<mutex_count; i++)
{
- sSSLMutex.push_back(new LLMutex(gAPRPoolp));
+ sSSLMutex.push_back(new LLMutex(NULL));
}
CRYPTO_set_id_callback(&LLCurl::ssl_thread_id);
CRYPTO_set_locking_callback(&LLCurl::ssl_locking_callback);