WIP: make everything use AICurlEasyRequestStateMachine
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
#include "lltimer.h" // ms_sleep
|
||||
#include "llproxy.h"
|
||||
#include "llhttpstatuscodes.h"
|
||||
#include "aihttpheaders.h"
|
||||
#ifdef CWDEBUG
|
||||
#include <libcwd/buf2str.h>
|
||||
#endif
|
||||
@@ -797,7 +798,7 @@ void CurlEasyRequest::setoptString(CURLoption option, std::string const& value)
|
||||
setopt(option, value.c_str());
|
||||
}
|
||||
|
||||
void CurlEasyRequest::setPost(AIPostFieldPtr const& postdata, S32 size)
|
||||
void CurlEasyRequest::setPost(AIPostFieldPtr const& postdata, U32 size)
|
||||
{
|
||||
llassert_always(postdata->data());
|
||||
|
||||
@@ -807,7 +808,7 @@ void CurlEasyRequest::setPost(AIPostFieldPtr const& postdata, S32 size)
|
||||
setPost_raw(size, postdata->data());
|
||||
}
|
||||
|
||||
void CurlEasyRequest::setPost_raw(S32 size, char const* data)
|
||||
void CurlEasyRequest::setPost_raw(U32 size, char const* data)
|
||||
{
|
||||
if (!data)
|
||||
{
|
||||
@@ -815,6 +816,9 @@ void CurlEasyRequest::setPost_raw(S32 size, char const* data)
|
||||
Dout(dc::curl, "POST size is " << size << " bytes.");
|
||||
}
|
||||
|
||||
// Accept everything (send an Accept-Encoding header containing all encodings we support (zlib and gzip)).
|
||||
setoptString(CURLOPT_ENCODING, ""); // CURLOPT_ACCEPT_ENCODING
|
||||
|
||||
// The server never replies with 100-continue, so suppress the "Expect: 100-continue" header that libcurl adds by default.
|
||||
addHeader("Expect:");
|
||||
if (size > 0)
|
||||
@@ -823,7 +827,7 @@ void CurlEasyRequest::setPost_raw(S32 size, char const* data)
|
||||
addHeader("Keep-alive: 300");
|
||||
}
|
||||
setopt(CURLOPT_POSTFIELDSIZE, size);
|
||||
setopt(CURLOPT_POSTFIELDS, data);
|
||||
setopt(CURLOPT_POSTFIELDS, data); // Implies CURLOPT_POST
|
||||
}
|
||||
|
||||
ThreadSafeCurlEasyRequest* CurlEasyRequest::get_lockobj(void)
|
||||
@@ -979,6 +983,12 @@ void CurlEasyRequest::addHeader(char const* header)
|
||||
mHeaders = curl_slist_append(mHeaders, header);
|
||||
}
|
||||
|
||||
void CurlEasyRequest::addHeaders(AIHTTPHeaders const& headers)
|
||||
{
|
||||
llassert(!mRequestFinalized);
|
||||
headers.append_to(mHeaders);
|
||||
}
|
||||
|
||||
#if defined(CWDEBUG) || defined(DEBUG_CURLIO)
|
||||
|
||||
static int curl_debug_cb(CURL*, curl_infotype infotype, char* buf, size_t size, void* user_ptr)
|
||||
@@ -1307,14 +1317,8 @@ ThreadSafeBufferedCurlEasyRequest* CurlResponderBuffer::get_lockobj(void)
|
||||
return static_cast<ThreadSafeBufferedCurlEasyRequest*>(AIThreadSafeSimple<CurlResponderBuffer>::wrapper_cast(this));
|
||||
}
|
||||
|
||||
void CurlResponderBuffer::prepRequest(AICurlEasyRequest_wat& curl_easy_request_w, std::vector<std::string> const& headers, AICurlInterface::ResponderPtr responder, S32 time_out, bool post)
|
||||
void CurlResponderBuffer::prepRequest(AICurlEasyRequest_wat& curl_easy_request_w, AIHTTPHeaders const& headers, AICurlInterface::ResponderPtr responder, S32 time_out)
|
||||
{
|
||||
if (post)
|
||||
{
|
||||
// Accept everything (send an Accept-Encoding header containing all encodings we support (zlib and gzip)).
|
||||
curl_easy_request_w->setoptString(CURLOPT_ENCODING, ""); // CURLOPT_ACCEPT_ENCODING
|
||||
}
|
||||
|
||||
mInput.reset(new LLBufferArray);
|
||||
mInput->setThreaded(true);
|
||||
mLastRead = NULL;
|
||||
@@ -1343,14 +1347,8 @@ void CurlResponderBuffer::prepRequest(AICurlEasyRequest_wat& curl_easy_request_w
|
||||
// Keep responder alive.
|
||||
mResponder = responder;
|
||||
|
||||
if (!post)
|
||||
{
|
||||
// Add extra headers.
|
||||
for (std::vector<std::string>::const_iterator iter = headers.begin(); iter != headers.end(); ++iter)
|
||||
{
|
||||
curl_easy_request_w->addHeader((*iter).c_str());
|
||||
}
|
||||
}
|
||||
// Add extra headers.
|
||||
curl_easy_request_w->addHeaders(headers);
|
||||
}
|
||||
|
||||
//static
|
||||
@@ -1500,7 +1498,12 @@ void CurlResponderBuffer::processOutput(AICurlEasyRequest_wat& curl_easy_request
|
||||
if (code == CURLE_OK)
|
||||
{
|
||||
curl_easy_request_w->getinfo(CURLINFO_RESPONSE_CODE, &responseCode);
|
||||
//AIFIXME: fill responseReason if (responseCode < 200 || responseCode >= 300).
|
||||
// If getResult code is CURLE_OK then we should have decoded the first header line ourselves.
|
||||
llassert(responseCode == mStatus);
|
||||
if (responseCode == mStatus)
|
||||
responseReason = mReason;
|
||||
else
|
||||
responseReason = "Unknown reason.";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/utility.hpp>
|
||||
|
||||
#include "llpreprocessor.h"
|
||||
@@ -49,11 +50,12 @@
|
||||
#define CURLOPT_DNS_USE_GLOBAL_CACHE do_not_use_CURLOPT_DNS_USE_GLOBAL_CACHE
|
||||
|
||||
#include "stdtypes.h" // U32
|
||||
#include "lliopipe.h" // LLIOPipe::buffer_ptr_t
|
||||
#include "llatomic.h" // LLAtomicU32
|
||||
#include "aithreadsafe.h"
|
||||
|
||||
class LLSD;
|
||||
class LLBufferArray;
|
||||
class LLChannelDescriptors;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exceptions.
|
||||
@@ -76,6 +78,11 @@ class AICurlNoMultiHandle : public AICurlError {
|
||||
AICurlNoMultiHandle(std::string const& message) : AICurlError(message) { }
|
||||
};
|
||||
|
||||
class AICurlNoBody : public AICurlError {
|
||||
public:
|
||||
AICurlNoBody(std::string const& message) : AICurlError(message) { }
|
||||
};
|
||||
|
||||
// End Exceptions.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -147,6 +154,9 @@ void setCAPath(std::string const& file);
|
||||
// destructed too.
|
||||
//
|
||||
class Responder {
|
||||
public:
|
||||
typedef boost::shared_ptr<LLBufferArray> buffer_ptr_t;
|
||||
|
||||
protected:
|
||||
Responder(void);
|
||||
virtual ~Responder();
|
||||
@@ -169,7 +179,7 @@ class Responder {
|
||||
|
||||
// Derived classes can override this to get the raw data of the body of the HTML message that was received.
|
||||
// The default is to interpret the content as LLSD and call completed().
|
||||
virtual void completedRaw(U32 status, std::string const& reason, LLChannelDescriptors const& channels, LLIOPipe::buffer_ptr_t const& buffer);
|
||||
virtual void completedRaw(U32 status, std::string const& reason, LLChannelDescriptors const& channels, buffer_ptr_t const& buffer);
|
||||
|
||||
// Called from LLHTTPClient request calls, if an error occurs even before we can call one of the above.
|
||||
// It calls completed() with a fake status U32_MAX, as that is what some derived clients expect (bad design).
|
||||
@@ -272,13 +282,19 @@ typedef LLPointer<AIPostField> AIPostFieldPtr;
|
||||
|
||||
// AICurlEasyRequest: a thread safe, reference counting, auto-cleaning curl easy handle.
|
||||
class AICurlEasyRequest {
|
||||
public:
|
||||
private:
|
||||
// Use AICurlEasyRequestStateMachine, not AICurlEasyRequest.
|
||||
friend class AICurlEasyRequestStateMachine;
|
||||
|
||||
// Initial construction is allowed (thread-safe).
|
||||
// Note: If ThreadSafeCurlEasyRequest() throws then the memory allocated is still freed.
|
||||
// 'new' never returned however and neither the constructor nor destructor of mCurlEasyRequest is called in this case.
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
AICurlEasyRequest(bool buffered) :
|
||||
mCurlEasyRequest(buffered ? new AICurlPrivate::ThreadSafeBufferedCurlEasyRequest : new AICurlPrivate::ThreadSafeCurlEasyRequest) { }
|
||||
|
||||
public:
|
||||
// Used for storing this object in a standard container (see MultiHandle::add_easy_request).
|
||||
AICurlEasyRequest(AICurlEasyRequest const& orig) : mCurlEasyRequest(orig.mCurlEasyRequest) { }
|
||||
|
||||
// For the rest, only allow read operations.
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
#include <sstream>
|
||||
#include "llatomic.h"
|
||||
|
||||
class AIHTTPHeaders;
|
||||
|
||||
namespace AICurlPrivate {
|
||||
namespace curlthread { class MultiHandle; }
|
||||
|
||||
@@ -213,13 +215,14 @@ class CurlEasyHandle : public boost::noncopyable, protected AICurlEasyHandleEven
|
||||
// and the CurlEasyRequest destructed.
|
||||
class CurlEasyRequest : public CurlEasyHandle {
|
||||
private:
|
||||
void setPost_raw(S32 size, char const* data);
|
||||
void setPost_raw(U32 size, char const* data);
|
||||
public:
|
||||
void setPost(S32 size) { setPost_raw(size, NULL); }
|
||||
void setPost(AIPostFieldPtr const& postdata, S32 size);
|
||||
void setPost(char const* data, S32 size) { setPost(new AIPostField(data), size); }
|
||||
void setPost(U32 size) { setPost_raw(size, NULL); }
|
||||
void setPost(AIPostFieldPtr const& postdata, U32 size);
|
||||
void setPost(char const* data, U32 size) { setPost(new AIPostField(data), size); }
|
||||
void setoptString(CURLoption option, std::string const& value);
|
||||
void addHeader(char const* str);
|
||||
void addHeaders(AIHTTPHeaders const& headers);
|
||||
|
||||
private:
|
||||
// Callback stubs.
|
||||
@@ -324,11 +327,13 @@ class CurlEasyRequest : public CurlEasyHandle {
|
||||
// is deleted and the CurlResponderBuffer destructed.
|
||||
class CurlResponderBuffer : protected AICurlEasyHandleEvents {
|
||||
public:
|
||||
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);
|
||||
typedef AICurlInterface::Responder::buffer_ptr_t buffer_ptr_t;
|
||||
|
||||
LLIOPipe::buffer_ptr_t& getInput(void) { return mInput; }
|
||||
LLIOPipe::buffer_ptr_t& getOutput(void) { return mOutput; }
|
||||
void resetState(AICurlEasyRequest_wat& curl_easy_request_w);
|
||||
void prepRequest(AICurlEasyRequest_wat& buffered_curl_easy_request_w, AIHTTPHeaders const& headers, AICurlInterface::ResponderPtr responder, S32 time_out = 0);
|
||||
|
||||
buffer_ptr_t& getInput(void) { return mInput; }
|
||||
buffer_ptr_t& getOutput(void) { return mOutput; }
|
||||
|
||||
// Called if libcurl doesn't deliver within mRequestTimeOut seconds.
|
||||
void timed_out(void);
|
||||
@@ -346,9 +351,9 @@ class CurlResponderBuffer : protected AICurlEasyHandleEvents {
|
||||
/*virtual*/ void removed_from_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w);
|
||||
|
||||
private:
|
||||
LLIOPipe::buffer_ptr_t mInput;
|
||||
buffer_ptr_t mInput;
|
||||
U8* mLastRead; // Pointer into mInput where we last stopped reading (or NULL to start at the beginning).
|
||||
LLIOPipe::buffer_ptr_t mOutput;
|
||||
buffer_ptr_t mOutput;
|
||||
AICurlInterface::ResponderPtr mResponder;
|
||||
//U32 mBodyLimit; // From the old LLURLRequestDetail::mBodyLimit, but never used.
|
||||
U32 mStatus; // HTTP status, decoded from the first header line.
|
||||
|
||||
@@ -702,7 +702,11 @@ CURLcode debug_curl_easy_setopt(CURL* handle, CURLoption option, ...)
|
||||
{
|
||||
LibcwDoutStream << "NULL";
|
||||
}
|
||||
LibcwDoutStream << "](" << (is_postfield ? postfieldsize : size) << " bytes))";
|
||||
LibcwDoutStream << "]";
|
||||
if (str)
|
||||
{
|
||||
LibcwDoutStream << "(" << (is_postfield ? postfieldsize : size) << " bytes))";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -227,7 +227,7 @@ public:
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @breif filesize helpers.
|
||||
* @brief filesize helpers.
|
||||
*
|
||||
* The file size helpers are not considered particularly efficient,
|
||||
* and should only be used for config files and the like -- not in a
|
||||
|
||||
@@ -179,7 +179,6 @@ LLMemType::DeclareMemType LLMemType::MTYPE_IO_BUFFER("IoBuffer");
|
||||
LLMemType::DeclareMemType LLMemType::MTYPE_IO_HTTP_SERVER("IoHttpServer");
|
||||
LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_SERVER("IoSDServer");
|
||||
LLMemType::DeclareMemType LLMemType::MTYPE_IO_SD_CLIENT("IoSDClient");
|
||||
LLMemType::DeclareMemType LLMemType::MTYPE_IO_URL_REQUEST("IOUrlRequest");
|
||||
|
||||
LLMemType::DeclareMemType LLMemType::MTYPE_DIRECTX_INIT("DirectXInit");
|
||||
|
||||
|
||||
@@ -223,7 +223,6 @@ public:
|
||||
static DeclareMemType MTYPE_IO_HTTP_SERVER;
|
||||
static DeclareMemType MTYPE_IO_SD_SERVER;
|
||||
static DeclareMemType MTYPE_IO_SD_CLIENT;
|
||||
static DeclareMemType MTYPE_IO_URL_REQUEST;
|
||||
|
||||
static DeclareMemType MTYPE_DIRECTX_INIT;
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg
|
||||
for(int i = 0; i < retries; ++i)
|
||||
{
|
||||
status_message = llformat("%s, try %d...", msg.c_str(), i+1);
|
||||
LLHTTPClient::post(host, data, new LLCrashLoggerResponder(), timeout);
|
||||
LLHTTPClient::post4(host, data, new LLCrashLoggerResponder(), timeout);
|
||||
while(!gBreak)
|
||||
{
|
||||
updateApplication(status_message);
|
||||
@@ -395,7 +395,6 @@ bool LLCrashLogger::init()
|
||||
}
|
||||
|
||||
gServicePump = new LLPumpIO;
|
||||
LLHTTPClient::setPump(*gServicePump);
|
||||
|
||||
//If we've opened the crash logger, assume we can delete the marker file if it exists
|
||||
if( gDirUtilp )
|
||||
|
||||
@@ -20,6 +20,7 @@ include_directories(
|
||||
)
|
||||
|
||||
set(llmessage_SOURCE_FILES
|
||||
aihttpheaders.cpp
|
||||
llhttpclient.cpp
|
||||
llares.cpp
|
||||
llareslistener.cpp
|
||||
@@ -104,6 +105,7 @@ set(llmessage_SOURCE_FILES
|
||||
set(llmessage_HEADER_FILES
|
||||
CMakeLists.txt
|
||||
|
||||
aihttpheaders.h
|
||||
llares.h
|
||||
llareslistener.h
|
||||
llassetstorage.h
|
||||
|
||||
107
indra/llmessage/aihttpheaders.cpp
Normal file
107
indra/llmessage/aihttpheaders.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @file aihttpheaders.cpp
|
||||
* @brief Implementation of AIHTTPHeaders
|
||||
*
|
||||
* Copyright (c) 2012, Aleric Inglewood.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 15/08/2012
|
||||
* Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
#include "sys.h"
|
||||
#include "aihttpheaders.h"
|
||||
#include <curl/curl.h>
|
||||
#ifdef DEBUG_CURLIO
|
||||
#include "debug_libcurl.h"
|
||||
#endif
|
||||
|
||||
AIHTTPHeaders::AIHTTPHeaders(void)
|
||||
{
|
||||
}
|
||||
|
||||
AIHTTPHeaders::AIHTTPHeaders(std::string const& key, std::string const& value) : mContainer(new Container)
|
||||
{
|
||||
addHeader(key, value);
|
||||
}
|
||||
|
||||
bool AIHTTPHeaders::addHeader(std::string const& key, std::string const& value, op_type op)
|
||||
{
|
||||
if (!mContainer)
|
||||
{
|
||||
mContainer = new Container;
|
||||
}
|
||||
insert_t res = mContainer->mKeyValuePairs.insert(container_t::value_type(key, value));
|
||||
bool key_already_exists = !res.second;
|
||||
if (key_already_exists)
|
||||
{
|
||||
llassert_always(op != new_header);
|
||||
if (op == replace_if_exists)
|
||||
res.first->second = value;
|
||||
}
|
||||
return key_already_exists;
|
||||
}
|
||||
|
||||
void AIHTTPHeaders::append_to(curl_slist*& slist) const
|
||||
{
|
||||
if (!mContainer)
|
||||
return;
|
||||
container_t::const_iterator const end = mContainer->mKeyValuePairs.end();
|
||||
for (container_t::const_iterator iter = mContainer->mKeyValuePairs.begin(); iter != end; ++iter)
|
||||
{
|
||||
slist = curl_slist_append(slist, llformat("%s: %s", iter->first.c_str(), iter->second.c_str()).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool AIHTTPHeaders::hasHeader(std::string const& key) const
|
||||
{
|
||||
return !mContainer ? false : (mContainer->mKeyValuePairs.find(key) != mContainer->mKeyValuePairs.end());
|
||||
}
|
||||
|
||||
bool AIHTTPHeaders::getValue(std::string const& key, std::string& value_out) const
|
||||
{
|
||||
AIHTTPHeaders::container_t::const_iterator iter;
|
||||
if (!mContainer || (iter = mContainer->mKeyValuePairs.find(key)) == mContainer->mKeyValuePairs.end())
|
||||
return false;
|
||||
value_out = iter->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, AIHTTPHeaders const& headers)
|
||||
{
|
||||
os << '{';
|
||||
if (headers.mContainer)
|
||||
{
|
||||
bool first = true;
|
||||
AIHTTPHeaders::container_t::const_iterator const end = headers.mContainer->mKeyValuePairs.end();
|
||||
for (AIHTTPHeaders::container_t::const_iterator iter = headers.mContainer->mKeyValuePairs.begin(); iter != end; ++iter)
|
||||
{
|
||||
if (!first)
|
||||
os << ", ";
|
||||
os << '"' << iter->first << ": " << iter->second << '"';
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
os << '}';
|
||||
return os;
|
||||
}
|
||||
|
||||
86
indra/llmessage/aihttpheaders.h
Normal file
86
indra/llmessage/aihttpheaders.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* @file aihttpheaders.h
|
||||
* @brief Keep a list of HTTP headers.
|
||||
*
|
||||
* Copyright (c) 2012, Aleric Inglewood.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* There are special exceptions to the terms and conditions of the GPL as
|
||||
* it is applied to this Source Code. View the full text of the exception
|
||||
* in the file doc/FLOSS-exception.txt in this software distribution.
|
||||
*
|
||||
* CHANGELOG
|
||||
* and additional copyright holders.
|
||||
*
|
||||
* 15/08/2012
|
||||
* Initial version, written by Aleric Inglewood @ SL
|
||||
*/
|
||||
|
||||
#ifndef AIHTTPHEADERS_H
|
||||
#define AIHTTPHEADERS_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <iosfwd>
|
||||
#include "llpointer.h"
|
||||
#include "llthread.h" // LLThreadSafeRefCount
|
||||
|
||||
extern "C" struct curl_slist;
|
||||
|
||||
class AIHTTPHeaders {
|
||||
public:
|
||||
enum op_type
|
||||
{
|
||||
new_header, // The inserted header must be the first one.
|
||||
replace_if_exists, // If a header of this type already exists, replace it. Otherwise add the header.
|
||||
keep_existing_header // If a header of this type already exists, do nothing.
|
||||
};
|
||||
|
||||
// Construct an empty container.
|
||||
AIHTTPHeaders(void);
|
||||
|
||||
// Construct a container with a single header.
|
||||
AIHTTPHeaders(std::string const& key, std::string const& value);
|
||||
|
||||
// Add a header. Returns true if the header already existed.
|
||||
bool addHeader(std::string const& key, std::string const& value, op_type op = new_header);
|
||||
|
||||
// Return true if there are no headers associated with this object.
|
||||
bool empty(void) const { return !mContainer || mContainer->mKeyValuePairs.empty(); }
|
||||
|
||||
// Return true if the header already exists.
|
||||
bool hasHeader(std::string const& key) const;
|
||||
|
||||
// Return true if key exists and full value_out with the value. Return false otherwise.
|
||||
bool getValue(std::string const& key, std::string& value_out) const;
|
||||
|
||||
// Append the headers to slist.
|
||||
void append_to(curl_slist*& slist) const;
|
||||
|
||||
// For debug purposes.
|
||||
friend std::ostream& operator<<(std::ostream& os, AIHTTPHeaders const& headers);
|
||||
|
||||
private:
|
||||
typedef std::map<std::string, std::string> container_t;
|
||||
typedef std::pair<container_t::iterator, bool> insert_t;
|
||||
|
||||
struct Container : public LLThreadSafeRefCount {
|
||||
container_t mKeyValuePairs;
|
||||
};
|
||||
|
||||
LLPointer<Container> mContainer;
|
||||
};
|
||||
|
||||
#endif // AIHTTPHEADERS_H
|
||||
@@ -382,7 +382,7 @@ void LLAvatarNameCache::requestNamesViaCapability()
|
||||
LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability first "
|
||||
<< ids << " ids"
|
||||
<< LL_ENDL;
|
||||
LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
|
||||
LLHTTPClient::get4(url, new LLAvatarNameResponder(agent_ids));
|
||||
url.clear();
|
||||
agent_ids.clear();
|
||||
}
|
||||
@@ -393,7 +393,7 @@ void LLAvatarNameCache::requestNamesViaCapability()
|
||||
LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::requestNamesViaCapability all "
|
||||
<< ids << " ids"
|
||||
<< LL_ENDL;
|
||||
LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
|
||||
LLHTTPClient::get4(url, new LLAvatarNameResponder(agent_ids));
|
||||
url.clear();
|
||||
agent_ids.clear();
|
||||
}
|
||||
|
||||
@@ -118,6 +118,17 @@ protected:
|
||||
//virtual streamsize xsputn(char* src, streamsize length);
|
||||
//@}
|
||||
|
||||
public:
|
||||
/*
|
||||
* @brief Return number of bytes in input channel.
|
||||
*/
|
||||
S32 count_in(void) const { return mBuffer->count(mChannels.in()); }
|
||||
|
||||
/*
|
||||
* @brief Return number of bytes in output channel.
|
||||
*/
|
||||
S32 count_out(void) const { return mBuffer->count(mChannels.out()); }
|
||||
|
||||
protected:
|
||||
// This channels we are working on.
|
||||
LLChannelDescriptors mChannels;
|
||||
@@ -144,6 +155,9 @@ public:
|
||||
LLBufferArray* buffer);
|
||||
~LLBufferStream();
|
||||
|
||||
S32 count_in(void) const { return mStreamBuf.count_in(); }
|
||||
S32 count_out(void) const { return mStreamBuf.count_out(); }
|
||||
|
||||
protected:
|
||||
LLBufferStreamBuf mStreamBuf;
|
||||
};
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "llcurlrequest.h"
|
||||
#include "llbufferstream.h"
|
||||
#include "aicurleasyrequeststatemachine.h"
|
||||
#include "aihttpheaders.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// class Request
|
||||
@@ -50,12 +51,13 @@
|
||||
|
||||
namespace AICurlInterface {
|
||||
|
||||
bool Request::get(std::string const& url, ResponderPtr responder)
|
||||
bool Request::get2(std::string const& url, ResponderPtr responder)
|
||||
{
|
||||
return getByteRange(url, headers_t(), 0, -1, responder);
|
||||
AIHTTPHeaders empty_headers;
|
||||
return getByteRange2(url, empty_headers, 0, -1, responder);
|
||||
}
|
||||
|
||||
bool Request::getByteRange(std::string const& url, headers_t const& headers, S32 offset, S32 length, ResponderPtr responder)
|
||||
bool Request::getByteRange2(std::string const& url, AIHTTPHeaders const& headers, S32 offset, S32 length, ResponderPtr responder)
|
||||
{
|
||||
DoutEntering(dc::curl, "Request::getByteRange(" << url << ", ...)");
|
||||
|
||||
@@ -63,7 +65,7 @@ bool Request::getByteRange(std::string const& url, headers_t const& headers, S32
|
||||
AICurlEasyRequestStateMachine* buffered_easy_request = new AICurlEasyRequestStateMachine(true);
|
||||
|
||||
{
|
||||
AICurlEasyRequest_wat buffered_easy_request_w(*buffered_easy_request->mCurlEasyRequest);
|
||||
AICurlEasyRequest_wat buffered_easy_request_w(*buffered_easy_request->mCurlEasyRequest);
|
||||
|
||||
AICurlResponderBuffer_wat(*buffered_easy_request->mCurlEasyRequest)->prepRequest(buffered_easy_request_w, headers, responder);
|
||||
|
||||
@@ -82,7 +84,7 @@ bool Request::getByteRange(std::string const& url, headers_t const& headers, S32
|
||||
return true; // We throw in case of problems.
|
||||
}
|
||||
|
||||
bool Request::post(std::string const& url, headers_t const& headers, std::string const& data, ResponderPtr responder, S32 time_out)
|
||||
bool Request::post2(std::string const& url, AIHTTPHeaders const& headers, std::string const& data, ResponderPtr responder, S32 time_out)
|
||||
{
|
||||
DoutEntering(dc::curl, "Request::post(" << url << ", ...)");
|
||||
|
||||
@@ -97,14 +99,14 @@ bool Request::post(std::string const& url, headers_t const& headers, std::string
|
||||
|
||||
U32 bytes = data.size();
|
||||
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->kill();
|
||||
throw AICurlNoBody("LLBufferArray::copyIntoBuffers() returned false");
|
||||
}
|
||||
buffered_easy_request_w->setPost(bytes);
|
||||
buffered_easy_request_w->addHeader("Content-Type: application/octet-stream");
|
||||
buffered_easy_request_w->finalizeRequest(url);
|
||||
|
||||
lldebugs << "POSTING: " << bytes << " bytes." << llendl;
|
||||
}
|
||||
|
||||
buffered_easy_request->run();
|
||||
@@ -112,7 +114,7 @@ bool Request::post(std::string const& url, headers_t const& headers, std::string
|
||||
return true; // We throw in case of problems.
|
||||
}
|
||||
|
||||
bool Request::post(std::string const& url, headers_t const& headers, LLSD const& data, ResponderPtr responder, S32 time_out)
|
||||
bool Request::post3(std::string const& url, AIHTTPHeaders const& headers, LLSD const& data, ResponderPtr responder, S32 time_out)
|
||||
{
|
||||
DoutEntering(dc::curl, "Request::post(" << url << ", ...)");
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <vector>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
|
||||
class AIHTTPHeaders;
|
||||
|
||||
// Things defined in this namespace are called from elsewhere in the viewer code.
|
||||
namespace AICurlInterface {
|
||||
|
||||
@@ -44,12 +46,10 @@ typedef boost::intrusive_ptr<Responder> ResponderPtr;
|
||||
|
||||
class Request {
|
||||
public:
|
||||
typedef std::vector<std::string> headers_t;
|
||||
|
||||
bool get(std::string const& url, ResponderPtr responder);
|
||||
bool getByteRange(std::string const& url, headers_t const& headers, S32 offset, S32 length, ResponderPtr responder);
|
||||
bool post(std::string const& url, headers_t const& headers, std::string const& data, ResponderPtr responder, S32 time_out = 0);
|
||||
bool post(std::string const& url, headers_t const& headers, LLSD const& data, ResponderPtr responder, S32 time_out = 0);
|
||||
bool get2(std::string const& url, ResponderPtr responder);
|
||||
bool getByteRange2(std::string const& url, AIHTTPHeaders const& headers, S32 offset, S32 length, ResponderPtr responder);
|
||||
bool post2(std::string const& url, AIHTTPHeaders const& headers, std::string const& data, ResponderPtr responder, S32 time_out = 0);
|
||||
bool post3(std::string const& url, AIHTTPHeaders const& headers, LLSD const& data, ResponderPtr responder, S32 time_out = 0);
|
||||
};
|
||||
|
||||
} // namespace AICurlInterface
|
||||
|
||||
@@ -25,191 +25,162 @@
|
||||
*/
|
||||
|
||||
#include "linden_common.h"
|
||||
#include "llhttpclient.h"
|
||||
|
||||
#include "llassetstorage.h"
|
||||
#include "lliopipe.h"
|
||||
#include "llurlrequest.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "llhttpclient.h"
|
||||
#include "llbufferstream.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llvfile.h"
|
||||
#include "llvfs.h"
|
||||
#include "lluri.h"
|
||||
#include "llpumpio.h" // LLPumpIO::chain_t
|
||||
#include "llurlrequest.h"
|
||||
|
||||
#include "message.h"
|
||||
|
||||
const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f;
|
||||
#ifdef AI_UNUSED
|
||||
#endif // AI_UNUSED
|
||||
F32 const HTTP_REQUEST_EXPIRY_SECS = 60.0f;
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Responder class moved to LLCurl
|
||||
|
||||
namespace
|
||||
{
|
||||
#if 0
|
||||
class LLHTTPClientURLAdaptor : public LLURLRequestComplete
|
||||
class LLHTTPClientURLAdaptor : public LLURLRequestComplete
|
||||
{
|
||||
public:
|
||||
LLHTTPClientURLAdaptor(LLCurl::ResponderPtr responder)
|
||||
: LLURLRequestComplete(), mResponder(responder), mStatus(499),
|
||||
mReason("LLURLRequest complete w/no status")
|
||||
{
|
||||
public:
|
||||
LLHTTPClientURLAdaptor(LLCurl::ResponderPtr responder)
|
||||
: LLURLRequestComplete(), mResponder(responder), mStatus(499),
|
||||
mReason("LLURLRequest complete w/no status")
|
||||
{
|
||||
}
|
||||
|
||||
~LLHTTPClientURLAdaptor()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
~LLHTTPClientURLAdaptor()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void httpStatus(U32 status, const std::string& reason)
|
||||
{
|
||||
LLURLRequestComplete::httpStatus(status,reason);
|
||||
virtual void httpStatus(U32 status, const std::string& reason)
|
||||
{
|
||||
LLURLRequestComplete::httpStatus(status,reason);
|
||||
|
||||
mStatus = status;
|
||||
mReason = reason;
|
||||
}
|
||||
mStatus = status;
|
||||
mReason = reason;
|
||||
}
|
||||
|
||||
virtual void complete(const LLChannelDescriptors& channels,
|
||||
const buffer_ptr_t& buffer)
|
||||
virtual void complete(const LLChannelDescriptors& channels,
|
||||
const buffer_ptr_t& buffer)
|
||||
{
|
||||
if (mResponder.get())
|
||||
{
|
||||
if (mResponder.get())
|
||||
{
|
||||
// Allow clients to parse headers before we attempt to parse
|
||||
// the body and provide completed/result/error calls.
|
||||
mResponder->completedHeader(mStatus, mReason, mHeaderOutput);
|
||||
mResponder->completedRaw(mStatus, mReason, channels, buffer);
|
||||
}
|
||||
}
|
||||
virtual void header(const std::string& header, const std::string& value)
|
||||
{
|
||||
mHeaderOutput[header] = value;
|
||||
// Allow clients to parse headers before we attempt to parse
|
||||
// the body and provide completed/result/error calls.
|
||||
mResponder->completedHeader(mStatus, mReason, mHeaderOutput);
|
||||
mResponder->completedRaw(mStatus, mReason, channels, buffer);
|
||||
}
|
||||
}
|
||||
virtual void header(const std::string& header, const std::string& value)
|
||||
{
|
||||
mHeaderOutput[header] = value;
|
||||
}
|
||||
|
||||
private:
|
||||
LLCurl::ResponderPtr mResponder;
|
||||
U32 mStatus;
|
||||
std::string mReason;
|
||||
LLSD mHeaderOutput;
|
||||
};
|
||||
private:
|
||||
LLCurl::ResponderPtr mResponder;
|
||||
U32 mStatus;
|
||||
std::string mReason;
|
||||
LLSD mHeaderOutput;
|
||||
};
|
||||
#endif
|
||||
|
||||
class Injector : public LLIOPipe
|
||||
class LLSDInjector : public Injector
|
||||
{
|
||||
public:
|
||||
LLSDInjector(LLSD const& sd) : mSD(sd) { }
|
||||
|
||||
/*virtual*/ char const* contentType(void) const { return "application/llsd+xml"; }
|
||||
|
||||
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
|
||||
{
|
||||
public:
|
||||
virtual const char* contentType() = 0;
|
||||
};
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
LLSDSerialize::toXML(mSD, ostream);
|
||||
//AIFIXME: remove this
|
||||
llassert(ostream.count_out() > 0 && ostream.count_in() == 0);
|
||||
return ostream.count_out();
|
||||
}
|
||||
|
||||
class LLSDInjector : public Injector
|
||||
LLSD const mSD;
|
||||
};
|
||||
|
||||
class RawInjector : public Injector
|
||||
{
|
||||
public:
|
||||
RawInjector(char const* data, U32 size) : mData(data), mSize(size) { }
|
||||
/*virtual*/ ~RawInjector() { delete [] mData; }
|
||||
|
||||
/*virtual*/ char const* contentType(void) const { return "application/octet-stream"; }
|
||||
|
||||
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
|
||||
{
|
||||
public:
|
||||
LLSDInjector(const LLSD& sd) : mSD(sd) {}
|
||||
virtual ~LLSDInjector() {}
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
ostream.write(mData, mSize);
|
||||
return mSize;
|
||||
}
|
||||
|
||||
const char* contentType() { return "application/llsd+xml"; }
|
||||
char const* mData;
|
||||
U32 mSize;
|
||||
};
|
||||
|
||||
virtual EStatus process_impl(const LLChannelDescriptors& channels,
|
||||
buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump)
|
||||
{
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
LLSDSerialize::toXML(mSD, ostream);
|
||||
eos = true;
|
||||
return STATUS_DONE;
|
||||
}
|
||||
class FileInjector : public Injector
|
||||
{
|
||||
public:
|
||||
FileInjector(std::string const& filename) : mFilename(filename) { }
|
||||
|
||||
const LLSD mSD;
|
||||
};
|
||||
char const* contentType(void) const { return "application/octet-stream"; }
|
||||
|
||||
class RawInjector : public Injector
|
||||
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
|
||||
{
|
||||
public:
|
||||
RawInjector(const U8* data, S32 size) : mData(data), mSize(size) {}
|
||||
virtual ~RawInjector() {delete [] mData;}
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
|
||||
const char* contentType() { return "application/octet-stream"; }
|
||||
llifstream fstream(mFilename, std::iostream::binary | std::iostream::out);
|
||||
if (!fstream.is_open())
|
||||
throw AICurlNoBody(llformat("Failed to open \"%s\".", mFilename.c_str()));
|
||||
|
||||
virtual EStatus process_impl(const LLChannelDescriptors& channels,
|
||||
buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump)
|
||||
{
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
ostream.write((const char *)mData, mSize); // hopefully chars are always U8s
|
||||
eos = true;
|
||||
return STATUS_DONE;
|
||||
}
|
||||
fstream.seekg(0, std::ios::end);
|
||||
U32 fileSize = fstream.tellg();
|
||||
fstream.seekg(0, std::ios::beg);
|
||||
std::vector<char> fileBuffer(fileSize);
|
||||
fstream.read(&fileBuffer[0], fileSize);
|
||||
ostream.write(&fileBuffer[0], fileSize);
|
||||
fstream.close();
|
||||
|
||||
const U8* mData;
|
||||
S32 mSize;
|
||||
};
|
||||
|
||||
class FileInjector : public Injector
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
std::string const mFilename;
|
||||
};
|
||||
|
||||
class VFileInjector : public Injector
|
||||
{
|
||||
public:
|
||||
VFileInjector(LLUUID const& uuid, LLAssetType::EType asset_type) : mUUID(uuid), mAssetType(asset_type) { }
|
||||
|
||||
/*virtual*/ char const* contentType(void) const { return "application/octet-stream"; }
|
||||
|
||||
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
|
||||
{
|
||||
public:
|
||||
FileInjector(const std::string& filename) : mFilename(filename) {}
|
||||
virtual ~FileInjector() {}
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
|
||||
LLVFile vfile(gVFS, mUUID, mAssetType, LLVFile::READ);
|
||||
S32 fileSize = vfile.getSize();
|
||||
std::vector<U8> fileBuffer(fileSize);
|
||||
vfile.read(&fileBuffer[0], fileSize);
|
||||
ostream.write((char*)&fileBuffer[0], fileSize);
|
||||
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
const char* contentType() { return "application/octet-stream"; }
|
||||
|
||||
virtual EStatus process_impl(const LLChannelDescriptors& channels,
|
||||
buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump)
|
||||
{
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
|
||||
llifstream fstream(mFilename, std::iostream::binary | std::iostream::out);
|
||||
if(fstream.is_open())
|
||||
{
|
||||
fstream.seekg(0, std::ios::end);
|
||||
U32 fileSize = fstream.tellg();
|
||||
fstream.seekg(0, std::ios::beg);
|
||||
std::vector<char> fileBuffer(fileSize);
|
||||
fstream.read(&fileBuffer[0], fileSize);
|
||||
ostream.write(&fileBuffer[0], fileSize);
|
||||
fstream.close();
|
||||
eos = true;
|
||||
return STATUS_DONE;
|
||||
}
|
||||
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
const std::string mFilename;
|
||||
};
|
||||
|
||||
class VFileInjector : public Injector
|
||||
{
|
||||
public:
|
||||
VFileInjector(const LLUUID& uuid, LLAssetType::EType asset_type) : mUUID(uuid), mAssetType(asset_type) {}
|
||||
virtual ~VFileInjector() {}
|
||||
|
||||
const char* contentType() { return "application/octet-stream"; }
|
||||
|
||||
virtual EStatus process_impl(const LLChannelDescriptors& channels,
|
||||
buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump)
|
||||
{
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
|
||||
LLVFile vfile(gVFS, mUUID, mAssetType, LLVFile::READ);
|
||||
S32 fileSize = vfile.getSize();
|
||||
std::vector<U8> fileBuffer(fileSize);
|
||||
vfile.read(&fileBuffer[0], fileSize);
|
||||
ostream.write((char*)&fileBuffer[0], fileSize);
|
||||
eos = true;
|
||||
return STATUS_DONE;
|
||||
}
|
||||
|
||||
const LLUUID mUUID;
|
||||
LLAssetType::EType mAssetType;
|
||||
};
|
||||
|
||||
LLPumpIO* theClientPump = NULL;
|
||||
}
|
||||
LLUUID const mUUID;
|
||||
LLAssetType::EType mAssetType;
|
||||
};
|
||||
|
||||
static void request(
|
||||
const std::string& url,
|
||||
LLURLRequest::ERequestAction method,
|
||||
Injector* body_injector,
|
||||
LLCurl::ResponderPtr responder,
|
||||
const F32 timeout = HTTP_REQUEST_EXPIRY_SECS,
|
||||
const LLSD& headers = LLSD())
|
||||
AIHTTPHeaders& headers,
|
||||
F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{
|
||||
if (responder)
|
||||
{
|
||||
@@ -217,17 +188,10 @@ static void request(
|
||||
responder->setURL(url);
|
||||
}
|
||||
|
||||
if (!LLHTTPClient::hasPump())
|
||||
{
|
||||
responder->fatalError("No pump");
|
||||
return;
|
||||
}
|
||||
LLPumpIO::chain_t chain;
|
||||
|
||||
LLURLRequest* req;
|
||||
try
|
||||
{
|
||||
req = new LLURLRequest(method, url);
|
||||
req = new LLURLRequest(method, url, body_injector, responder, headers);
|
||||
}
|
||||
catch(AICurlNoEasyHandle& error)
|
||||
{
|
||||
@@ -236,140 +200,40 @@ static void request(
|
||||
return ;
|
||||
}
|
||||
|
||||
req->checkRootCertificate(true);
|
||||
|
||||
lldebugs << LLURLRequest::actionAsVerb(method) << " " << url << " " << headers << llendl;
|
||||
|
||||
// Insert custom headers if the caller sent any.
|
||||
|
||||
std::vector<std::string> headers_vector;
|
||||
bool has_content_type = false;
|
||||
bool has_accept = false;
|
||||
|
||||
// Note that headers always is a map, unless no argument was passed.
|
||||
if (headers.isMap())
|
||||
{
|
||||
if (headers.has("Cookie"))
|
||||
{
|
||||
req->allowCookies();
|
||||
}
|
||||
|
||||
LLSD::map_const_iterator iter = headers.beginMap();
|
||||
LLSD::map_const_iterator const end = headers.endMap();
|
||||
|
||||
for (; iter != end; ++iter)
|
||||
{
|
||||
// If the header is "Pragma" with no value, the caller intends to
|
||||
// force libcurl to drop the Pragma header it so gratuitously inserts.
|
||||
// Before inserting the header, force libcurl to not use the proxy.
|
||||
if (iter->first.compare("Pragma") == 0 && iter->second.asString().empty())
|
||||
{
|
||||
req->useProxy(false);
|
||||
}
|
||||
if (iter->first.compare("Content-Type") == 0)
|
||||
{
|
||||
has_content_type = true;
|
||||
}
|
||||
if (iter->first.compare("Accept") == 0)
|
||||
{
|
||||
has_accept = true;
|
||||
}
|
||||
|
||||
std::ostringstream header;
|
||||
header << iter->first << ": " << iter->second.asString();
|
||||
headers_vector.push_back(header.str());
|
||||
}
|
||||
}
|
||||
|
||||
if (method == LLURLRequest::HTTP_PUT || method == LLURLRequest::HTTP_POST)
|
||||
{
|
||||
if (!has_content_type)
|
||||
{
|
||||
// If the Content-Type header was passed in, it has
|
||||
// already been added as a header through req->addHeader
|
||||
// in the loop above. We defer to the caller's wisdom, but
|
||||
// if they did not specify a Content-Type, then ask the
|
||||
// injector.
|
||||
headers_vector.push_back(llformat("Content-Type: %s", body_injector->contentType()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check to see if we have already set Accept or not. If no one
|
||||
// set it, set it to application/llsd+xml since that's what we
|
||||
// almost always want.
|
||||
if (!has_accept)
|
||||
{
|
||||
headers_vector.push_back("Accept: application/llsd+xml");
|
||||
}
|
||||
}
|
||||
if (method == LLURLRequest::HTTP_POST && gMessageSystem)
|
||||
{
|
||||
headers_vector.push_back(llformat("X-SecondLife-UDP-Listen-Port: %d", gMessageSystem->mPort));
|
||||
}
|
||||
|
||||
if (method == LLURLRequest::HTTP_PUT || method == LLURLRequest::HTTP_POST)
|
||||
{
|
||||
//AIFIXME:
|
||||
chain.push_back(LLIOPipe::ptr_t(body_injector));
|
||||
}
|
||||
|
||||
//AIFIXME: chain.push_back(LLIOPipe::ptr_t(req));
|
||||
|
||||
AICurlEasyRequest_wat buffered_easy_request_w(*req->mCurlEasyRequest);
|
||||
AICurlResponderBuffer_wat buffer_w(*req->mCurlEasyRequest);
|
||||
buffer_w->prepRequest(buffered_easy_request_w, headers_vector, responder);
|
||||
|
||||
req->setRequestTimeOut(timeout);
|
||||
//AIFIXME: theClientPump->addChain(chain, timeout);
|
||||
req->run();
|
||||
}
|
||||
|
||||
|
||||
void LLHTTPClient::getByteRange(
|
||||
const std::string& url,
|
||||
S32 offset,
|
||||
S32 bytes,
|
||||
ResponderPtr responder,
|
||||
const LLSD& hdrs,
|
||||
const F32 timeout)
|
||||
void LLHTTPClient::getByteRange4(std::string const& url, S32 offset, S32 bytes, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
LLSD headers = hdrs;
|
||||
if(offset > 0 || bytes > 0)
|
||||
{
|
||||
std::string range = llformat("bytes=%d-%d", offset, offset+bytes-1);
|
||||
headers["Range"] = range;
|
||||
headers.addHeader("Range", llformat("bytes=%d-%d", offset, offset + bytes - 1));
|
||||
}
|
||||
request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_GET, NULL, responder, headers, timeout);
|
||||
}
|
||||
|
||||
void LLHTTPClient::head(
|
||||
const std::string& url,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers,
|
||||
const F32 timeout)
|
||||
void LLHTTPClient::head4(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, headers, timeout);
|
||||
}
|
||||
|
||||
void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout)
|
||||
void LLHTTPClient::get4(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout, headers);
|
||||
}
|
||||
void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, timeout, headers);
|
||||
}
|
||||
void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const F32 timeout)
|
||||
{
|
||||
getHeaderOnly(url, responder, LLSD(), timeout);
|
||||
request(url, LLURLRequest::HTTP_GET, NULL, responder, headers, timeout);
|
||||
}
|
||||
|
||||
void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const LLSD& headers, const F32 timeout)
|
||||
void LLHTTPClient::getHeaderOnly4(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_HEAD, NULL, responder, headers, timeout);
|
||||
}
|
||||
|
||||
void LLHTTPClient::get4(std::string const& url, LLSD const& query, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
LLURI uri;
|
||||
|
||||
uri = LLURI::buildHTTP(url, LLSD::emptyArray(), query);
|
||||
get(uri.asString(), responder, headers, timeout);
|
||||
get4(uri.asString(), responder, headers, timeout);
|
||||
}
|
||||
|
||||
// A simple class for managing data returned from a curl http request.
|
||||
@@ -426,18 +290,18 @@ private:
|
||||
@returns an LLSD map: {status: integer, body: map}
|
||||
*/
|
||||
static LLSD blocking_request(
|
||||
const std::string& url,
|
||||
std::string const& url,
|
||||
LLURLRequest::ERequestAction method,
|
||||
const LLSD& body,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout = 5
|
||||
)
|
||||
LLSD const& body,
|
||||
AIHTTPHeaders& headers,
|
||||
F32 timeout = 5)
|
||||
{
|
||||
lldebugs << "blockingRequest of " << url << llendl;
|
||||
|
||||
S32 http_status = 499;
|
||||
LLSD response = LLSD::emptyMap();
|
||||
|
||||
#if 0 // AIFIXME: rewrite to use AICurlEasyRequestStateMachine
|
||||
try
|
||||
{
|
||||
AICurlEasyRequest easy_request(false);
|
||||
@@ -508,6 +372,7 @@ static LLSD blocking_request(
|
||||
{
|
||||
response["body"] = error.what();
|
||||
}
|
||||
#endif
|
||||
|
||||
response["status"] = http_status;
|
||||
return response;
|
||||
@@ -515,104 +380,50 @@ static LLSD blocking_request(
|
||||
|
||||
LLSD LLHTTPClient::blockingGet(const std::string& url)
|
||||
{
|
||||
return blocking_request(url, LLURLRequest::HTTP_GET, LLSD());
|
||||
AIHTTPHeaders empty_headers;
|
||||
return blocking_request(url, LLURLRequest::HTTP_GET, LLSD(), empty_headers);
|
||||
}
|
||||
|
||||
LLSD LLHTTPClient::blockingPost(const std::string& url, const LLSD& body)
|
||||
{
|
||||
return blocking_request(url, LLURLRequest::HTTP_POST, body);
|
||||
AIHTTPHeaders empty_headers;
|
||||
return blocking_request(url, LLURLRequest::HTTP_POST, body, empty_headers);
|
||||
}
|
||||
|
||||
void LLHTTPClient::put(
|
||||
const std::string& url,
|
||||
const LLSD& body,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers,
|
||||
const F32 timeout)
|
||||
void LLHTTPClient::put4(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_PUT, new LLSDInjector(body), responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_PUT, new LLSDInjector(body), responder, headers, timeout);
|
||||
}
|
||||
|
||||
void LLHTTPClient::post(
|
||||
const std::string& url,
|
||||
const LLSD& body,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers,
|
||||
const F32 timeout)
|
||||
void LLHTTPClient::post4(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_POST, new LLSDInjector(body), responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_POST, new LLSDInjector(body), responder, headers, timeout);
|
||||
}
|
||||
|
||||
void LLHTTPClient::postRaw(
|
||||
const std::string& url,
|
||||
const U8* data,
|
||||
S32 size,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers,
|
||||
const F32 timeout)
|
||||
void LLHTTPClient::postRaw4(std::string const& url, char const* data, S32 size, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_POST, new RawInjector(data, size), responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_POST, new RawInjector(data, size), responder, headers, timeout);
|
||||
}
|
||||
|
||||
void LLHTTPClient::postFile(
|
||||
const std::string& url,
|
||||
const std::string& filename,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers,
|
||||
const F32 timeout)
|
||||
void LLHTTPClient::postFile4(std::string const& url, std::string const& filename, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_POST, new FileInjector(filename), responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_POST, new FileInjector(filename), responder, headers, timeout);
|
||||
}
|
||||
|
||||
void LLHTTPClient::postFile(
|
||||
const std::string& url,
|
||||
const LLUUID& uuid,
|
||||
LLAssetType::EType asset_type,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers,
|
||||
const F32 timeout)
|
||||
void LLHTTPClient::postFile4(std::string const& url, LLUUID const& uuid, LLAssetType::EType asset_type, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_POST, new VFileInjector(uuid, asset_type), responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_POST, new VFileInjector(uuid, asset_type), responder, headers, timeout);
|
||||
}
|
||||
|
||||
// static
|
||||
void LLHTTPClient::del(
|
||||
const std::string& url,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers,
|
||||
const F32 timeout)
|
||||
void LLHTTPClient::del4(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_DELETE, NULL, responder, timeout, headers);
|
||||
request(url, LLURLRequest::HTTP_DELETE, NULL, responder, headers, timeout);
|
||||
}
|
||||
|
||||
// static
|
||||
void LLHTTPClient::move(
|
||||
const std::string& url,
|
||||
const std::string& destination,
|
||||
ResponderPtr responder,
|
||||
const LLSD& hdrs,
|
||||
const F32 timeout)
|
||||
void LLHTTPClient::move4(std::string const& url, std::string const& destination, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout)
|
||||
{
|
||||
LLSD headers = hdrs;
|
||||
headers["Destination"] = destination;
|
||||
request(url, LLURLRequest::HTTP_MOVE, NULL, responder, timeout, headers);
|
||||
}
|
||||
|
||||
|
||||
//static
|
||||
void LLHTTPClient::setPump(LLPumpIO& pump)
|
||||
{
|
||||
theClientPump = &pump;
|
||||
}
|
||||
|
||||
//static
|
||||
bool LLHTTPClient::hasPump()
|
||||
{
|
||||
return theClientPump != NULL;
|
||||
}
|
||||
|
||||
//static
|
||||
LLPumpIO& LLHTTPClient::getPump()
|
||||
{
|
||||
return *theClientPump;
|
||||
headers.addHeader("Destination", destination);
|
||||
request(url, LLURLRequest::HTTP_MOVE, NULL, responder, headers, timeout);
|
||||
}
|
||||
|
||||
@@ -33,23 +33,19 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include "llassettype.h"
|
||||
#include "llcurl.h"
|
||||
#include "lliopipe.h"
|
||||
#include "aihttpheaders.h"
|
||||
|
||||
extern const F32 HTTP_REQUEST_EXPIRY_SECS;
|
||||
extern F32 const HTTP_REQUEST_EXPIRY_SECS;
|
||||
|
||||
class LLUUID;
|
||||
class LLPumpIO;
|
||||
class LLSD;
|
||||
|
||||
|
||||
class LLHTTPClient
|
||||
{
|
||||
public:
|
||||
// class Responder moved to LLCurl
|
||||
|
||||
// For convenience
|
||||
typedef LLCurl::Responder Responder;
|
||||
typedef LLCurl::ResponderPtr ResponderPtr;
|
||||
@@ -59,57 +55,51 @@ public:
|
||||
|
||||
/** @name non-blocking API */
|
||||
//@{
|
||||
static void head(
|
||||
const std::string& url,
|
||||
ResponderPtr,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getByteRange(const std::string& url, S32 offset, S32 bytes, ResponderPtr, const LLSD& headers=LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void get(const std::string& url, ResponderPtr, const LLSD& headers = LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void get(const std::string& url, const LLSD& query, ResponderPtr, const LLSD& headers = LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void head4(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void head4(std::string const& url, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; head4(url, responder, headers, timeout); }
|
||||
|
||||
static void put(
|
||||
const std::string& url,
|
||||
const LLSD& body,
|
||||
ResponderPtr,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getHeaderOnly(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getHeaderOnly(const std::string& url, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getByteRange4(std::string const& url, S32 offset, S32 bytes, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getByteRange4(std::string const& url, S32 offset, S32 bytes, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; getByteRange4(url, offset, bytes, responder, headers, timeout); }
|
||||
|
||||
static void get4(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void get4(std::string const& url, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; get4(url, responder, headers, timeout); }
|
||||
|
||||
static void get4(std::string const& url, LLSD const& query, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void get4(std::string const& url, LLSD const& query, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; get4(url, query, responder, headers, timeout); }
|
||||
|
||||
static void put4(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void put4(std::string const& url, LLSD const& body, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; put4(url, body, responder, headers, timeout); }
|
||||
|
||||
static void getHeaderOnly4(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void getHeaderOnly4(std::string const& url, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; getHeaderOnly4(url, responder, headers, timeout); }
|
||||
|
||||
static void post4(std::string const& url, LLSD const& body, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void post4(std::string const& url, LLSD const& body, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; post4(url, body, responder, headers, timeout); }
|
||||
|
||||
static void post(
|
||||
const std::string& url,
|
||||
const LLSD& body,
|
||||
ResponderPtr,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
/** Takes ownership of data and deletes it when sent */
|
||||
static void postRaw(
|
||||
const std::string& url,
|
||||
const U8* data,
|
||||
S32 size,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void postFile(
|
||||
const std::string& url,
|
||||
const std::string& filename,
|
||||
ResponderPtr,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void postFile(
|
||||
const std::string& url,
|
||||
const LLUUID& uuid,
|
||||
LLAssetType::EType asset_type,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void postRaw4(std::string const& url, const char* data, S32 size, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void postRaw4(std::string const& url, const char* data, S32 size, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; postRaw4(url, data, size, responder, headers, timeout); }
|
||||
|
||||
static void postFile4(std::string const& url, std::string const& filename, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void postFile4(std::string const& url, std::string const& filename, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; postFile4(url, filename, responder, headers, timeout); }
|
||||
|
||||
static void postFile4(std::string const& url, const LLUUID& uuid, LLAssetType::EType asset_type, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void postFile4(std::string const& url, const LLUUID& uuid, LLAssetType::EType asset_type, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; postFile4(url, uuid, asset_type, responder, headers, timeout); }
|
||||
|
||||
static void del4(std::string const& url, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void del4(std::string const& url, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; del4(url, responder, headers, timeout); }
|
||||
|
||||
static void del(
|
||||
const std::string& url,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
///< sends a DELETE method, but we can't call it delete in c++
|
||||
|
||||
/**
|
||||
@@ -121,12 +111,9 @@ public:
|
||||
* @param headers A map of key:value headers to pass to the request
|
||||
* @param timeout The number of seconds to give the server to respond.
|
||||
*/
|
||||
static void move(
|
||||
const std::string& url,
|
||||
const std::string& destination,
|
||||
ResponderPtr responder,
|
||||
const LLSD& headers = LLSD(),
|
||||
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void move4(std::string const& url, std::string const& destination, ResponderPtr responder, AIHTTPHeaders& headers, F32 timeout = HTTP_REQUEST_EXPIRY_SECS);
|
||||
static void move4(std::string const& url, std::string const& destination, ResponderPtr responder, F32 timeout = HTTP_REQUEST_EXPIRY_SECS)
|
||||
{ AIHTTPHeaders headers; move4(url, destination, responder, headers, timeout); }
|
||||
|
||||
//@}
|
||||
|
||||
@@ -136,7 +123,7 @@ public:
|
||||
* @param url the complete serialized (and escaped) url to get
|
||||
* @return An LLSD of { 'status':status, 'body':payload }
|
||||
*/
|
||||
static LLSD blockingGet(const std::string& url);
|
||||
static LLSD blockingGet(std::string const& url);
|
||||
|
||||
/**
|
||||
* @brief Blocking HTTP POST that returns an LLSD map of status and body.
|
||||
@@ -145,17 +132,7 @@ public:
|
||||
* @param body the LLSD post body
|
||||
* @return An LLSD of { 'status':status (an int), 'body':payload (an LLSD) }
|
||||
*/
|
||||
static LLSD blockingPost(const std::string& url, const LLSD& body);
|
||||
|
||||
|
||||
static void setPump(LLPumpIO& pump);
|
||||
///< must be called before any of the above calls are made
|
||||
static bool hasPump();
|
||||
///< for testing
|
||||
static LLPumpIO &getPump();
|
||||
///< Hippo special
|
||||
#ifdef AI_UNUSED
|
||||
#endif // AI_UNUSED
|
||||
static LLSD blockingPost(std::string const& url, LLSD const& body);
|
||||
};
|
||||
|
||||
#endif // LL_LLHTTPCLIENT_H
|
||||
|
||||
@@ -33,23 +33,21 @@ LLHTTPClientAdapter::~LLHTTPClientAdapter()
|
||||
|
||||
void LLHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder)
|
||||
{
|
||||
LLSD empty_pragma_header;
|
||||
// Pragma is required to stop curl adding "no-cache"
|
||||
// Space is required to stop llurlrequest from turnning off proxying
|
||||
empty_pragma_header["Pragma"] = " ";
|
||||
LLHTTPClient::get(url, responder, empty_pragma_header);
|
||||
AIHTTPHeaders empty_pragma_header("Pragma", " ");
|
||||
LLHTTPClient::get4(url, responder, empty_pragma_header);
|
||||
}
|
||||
|
||||
void LLHTTPClientAdapter::get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers)
|
||||
{
|
||||
LLSD empty_pragma_header = headers;
|
||||
// as above
|
||||
empty_pragma_header["Pragma"] = " ";
|
||||
LLHTTPClient::get(url, responder, empty_pragma_header);
|
||||
AIHTTPHeaders empty_pragma_header("Pragma", " ");
|
||||
LLHTTPClient::get4(url, responder, empty_pragma_header);
|
||||
}
|
||||
|
||||
void LLHTTPClientAdapter::put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder)
|
||||
{
|
||||
LLHTTPClient::put(url, body, responder);
|
||||
LLHTTPClient::put4(url, body, responder);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ void LLHTTPSender::send(const LLHost& host, const std::string& name,
|
||||
std::ostringstream stream;
|
||||
stream << "http://" << host << "/trusted-message/" << name;
|
||||
llinfos << "LLHTTPSender::send: POST to " << stream.str() << llendl;
|
||||
LLHTTPClient::post(stream.str(), body, response);
|
||||
LLHTTPClient::post4(stream.str(), body, response);
|
||||
}
|
||||
|
||||
//static
|
||||
|
||||
@@ -83,11 +83,10 @@ bool LLSDMessage::httpListener(const LLSD& request)
|
||||
{
|
||||
timeout = HTTP_REQUEST_EXPIRY_SECS;
|
||||
}
|
||||
LLHTTPClient::post(url, payload,
|
||||
LLHTTPClient::post4(url, payload,
|
||||
new LLSDMessage::EventResponder(LLEventPumps::instance(),
|
||||
request,
|
||||
url, "POST", reply, error),
|
||||
LLSD(), // headers
|
||||
(F32)timeout);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
#include "llapr.h"
|
||||
#include "llscopedvolatileaprpool.h"
|
||||
#include "llfasttimer.h"
|
||||
#include "message.h"
|
||||
static const U32 HTTP_STATUS_PIPE_ERROR = 499;
|
||||
|
||||
/**
|
||||
@@ -112,10 +113,75 @@ std::string LLURLRequest::actionAsVerb(LLURLRequest::ERequestAction action)
|
||||
}
|
||||
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, std::string const& url) : AICurlEasyRequestStateMachine(true), mAction(action), mURL(url)
|
||||
LLURLRequest::LLURLRequest(LLURLRequest::ERequestAction action, std::string const& url, Injector* body, AICurlInterface::ResponderPtr responder, AIHTTPHeaders& headers) :
|
||||
AICurlEasyRequestStateMachine(true), mAction(action), mURL(url), mBody(body), mResponder(responder), mHeaders(headers)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
run();
|
||||
}
|
||||
|
||||
void LLURLRequest::initialize_impl(void)
|
||||
{
|
||||
if (mHeaders.hasHeader("Cookie"))
|
||||
{
|
||||
allowCookies();
|
||||
}
|
||||
|
||||
// If the header is "Pragma" with no value, the caller intends to
|
||||
// force libcurl to drop the Pragma header it so gratuitously inserts.
|
||||
// Before inserting the header, force libcurl to not use the proxy.
|
||||
std::string pragma_value;
|
||||
if (mHeaders.getValue("Pragma", pragma_value) && pragma_value.empty())
|
||||
{
|
||||
useProxy(false);
|
||||
}
|
||||
|
||||
if (mAction == HTTP_PUT || mAction == HTTP_POST)
|
||||
{
|
||||
// If the Content-Type header was passed in we defer to the caller's wisdom,
|
||||
// but if they did not specify a Content-Type, then ask the injector.
|
||||
mHeaders.addHeader("Content-Type", mBody->contentType(), AIHTTPHeaders::keep_existing_header);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check to see if we have already set Accept or not. If no one
|
||||
// set it, set it to application/llsd+xml since that's what we
|
||||
// almost always want.
|
||||
mHeaders.addHeader("Accept", "application/llsd+xml", AIHTTPHeaders::keep_existing_header);
|
||||
}
|
||||
|
||||
if (mAction == HTTP_POST && gMessageSystem)
|
||||
{
|
||||
mHeaders.addHeader("X-SecondLife-UDP-Listen-Port", llformat("%d", gMessageSystem->mPort));
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
try
|
||||
{
|
||||
AICurlEasyRequest_wat buffered_easy_request_w(*mCurlEasyRequest);
|
||||
AICurlResponderBuffer_wat buffer_w(*mCurlEasyRequest);
|
||||
buffer_w->prepRequest(buffered_easy_request_w, mHeaders, mResponder);
|
||||
|
||||
if (mBody)
|
||||
{
|
||||
// This might throw AICurlNoBody.
|
||||
mBodySize = mBody->get_body(buffer_w->sChannels, buffer_w->getInput());
|
||||
}
|
||||
|
||||
success = configure(buffered_easy_request_w);
|
||||
}
|
||||
catch (AICurlNoBody const& error)
|
||||
{
|
||||
llwarns << "Injector::get_body() failed: " << error.what() << llendl;
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
// Continue to initialize base class.
|
||||
AICurlEasyRequestStateMachine::initialize_impl();
|
||||
}
|
||||
else
|
||||
{
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -132,18 +198,10 @@ std::string LLURLRequest::getURL2() const
|
||||
|
||||
void LLURLRequest::addHeader(const char* header)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
AICurlEasyRequest_wat curlEasyRequest_w(*mCurlEasyRequest);
|
||||
curlEasyRequest_w->addHeader(header);
|
||||
}
|
||||
|
||||
void LLURLRequest::checkRootCertificate(bool check)
|
||||
{
|
||||
AICurlEasyRequest_wat curlEasyRequest_w(*mCurlEasyRequest);
|
||||
curlEasyRequest_w->setopt(CURLOPT_SSL_VERIFYPEER, check ? 1L : 0L);
|
||||
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, "");
|
||||
}
|
||||
|
||||
#ifdef AI_UNUSED
|
||||
void LLURLRequest::setBodyLimit(U32 size)
|
||||
{
|
||||
@@ -153,7 +211,6 @@ void LLURLRequest::setBodyLimit(U32 size)
|
||||
|
||||
void LLURLRequest::setCallback(LLURLRequestComplete* callback)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
mCompletionCallback = callback;
|
||||
AICurlEasyRequest_wat curlEasyRequest_w(*mCurlEasyRequest);
|
||||
curlEasyRequest_w->setHeaderCallback(&headerCallback, (void*)callback);
|
||||
@@ -237,7 +294,6 @@ LLIOPipe::EStatus LLURLRequest::handleError(
|
||||
LLPumpIO* pump)
|
||||
{
|
||||
DoutEntering(dc::curl, "LLURLRequest::handleError(" << LLIOPipe::lookupStatusString(status) << ", " << (void*)pump << ")");
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
|
||||
if (LL_LIKELY(!mDetail->mStateMachine->isBuffered())) // Currently always true.
|
||||
{
|
||||
@@ -283,12 +339,12 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
|
||||
{
|
||||
LLFastTimer t(FTM_PROCESS_URL_REQUEST);
|
||||
PUMP_DEBUG;
|
||||
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.
|
||||
|
||||
//AIFIXME: implement this again:
|
||||
// we're still waiting or processing, check how many
|
||||
// bytes we have accumulated.
|
||||
const S32 MIN_ACCUMULATION = 100000;
|
||||
@@ -433,22 +489,10 @@ LLIOPipe::EStatus LLURLRequest::process_impl(
|
||||
}
|
||||
#endif // AI_UNUSED
|
||||
|
||||
S32 LLURLRequest::bytes_to_send(void) const
|
||||
bool LLURLRequest::configure(AICurlEasyRequest_wat const& curlEasyRequest_w)
|
||||
{
|
||||
//AIFIXME: how to get the number of bytes to send?
|
||||
llassert_always(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static LLFastTimer::DeclareTimer FTM_URL_REQUEST_CONFIGURE("URL Configure");
|
||||
bool LLURLRequest::configure()
|
||||
{
|
||||
LLFastTimer t(FTM_URL_REQUEST_CONFIGURE);
|
||||
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
bool rv = false;
|
||||
{
|
||||
AICurlEasyRequest_wat curlEasyRequest_w(*mCurlEasyRequest);
|
||||
switch(mAction)
|
||||
{
|
||||
case HTTP_HEAD:
|
||||
@@ -472,20 +516,15 @@ bool LLURLRequest::configure()
|
||||
// Disable the expect http 1.1 extension. POST and PUT default
|
||||
// to turning this on, and I am not too sure what it means.
|
||||
curlEasyRequest_w->addHeader("Expect:");
|
||||
S32 bytes = bytes_to_send();
|
||||
curlEasyRequest_w->setopt(CURLOPT_UPLOAD, 1);
|
||||
curlEasyRequest_w->setopt(CURLOPT_INFILESIZE, bytes);
|
||||
curlEasyRequest_w->setopt(CURLOPT_INFILESIZE, mBodySize);
|
||||
rv = true;
|
||||
break;
|
||||
}
|
||||
case HTTP_POST:
|
||||
{
|
||||
// Set the handle for an http post
|
||||
S32 bytes = bytes_to_send();
|
||||
curlEasyRequest_w->setPost(bytes);
|
||||
|
||||
// Set Accept-Encoding to allow response compression
|
||||
curlEasyRequest_w->setoptString(CURLOPT_ENCODING, "");
|
||||
curlEasyRequest_w->setPost(mBodySize);
|
||||
rv = true;
|
||||
break;
|
||||
}
|
||||
@@ -498,7 +537,6 @@ bool LLURLRequest::configure()
|
||||
case HTTP_MOVE:
|
||||
// Set the handle for an http post
|
||||
curlEasyRequest_w->setoptString(CURLOPT_CUSTOMREQUEST, "MOVE");
|
||||
// *NOTE: should we check for the Destination header?
|
||||
rv = true;
|
||||
break;
|
||||
|
||||
@@ -522,7 +560,6 @@ size_t LLURLRequest::downCallback(
|
||||
size_t nmemb,
|
||||
void* user)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
LLURLRequest* req = (LLURLRequest*)user;
|
||||
if(STATE_WAITING_FOR_RESPONSE == req->mState)
|
||||
{
|
||||
@@ -558,7 +595,6 @@ size_t LLURLRequest::upCallback(
|
||||
size_t nmemb,
|
||||
void* user)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
LLURLRequest* req = (LLURLRequest*)user;
|
||||
S32 bytes = llmin(
|
||||
(S32)(size * nmemb),
|
||||
@@ -649,13 +685,11 @@ static size_t headerCallback(char* header_line, size_t size, size_t nmemb, void*
|
||||
LLURLRequestComplete::LLURLRequestComplete() :
|
||||
mRequestStatus(LLIOPipe::STATUS_ERROR)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
}
|
||||
|
||||
// virtual
|
||||
LLURLRequestComplete::~LLURLRequestComplete()
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
}
|
||||
|
||||
//virtual
|
||||
@@ -694,7 +728,6 @@ void LLURLRequestComplete::noResponse()
|
||||
|
||||
void LLURLRequestComplete::responseStatus(LLIOPipe::EStatus status)
|
||||
{
|
||||
LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
|
||||
mRequestStatus = status;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,15 @@
|
||||
|
||||
#include <string>
|
||||
#include "aicurleasyrequeststatemachine.h"
|
||||
#include "aihttpheaders.h"
|
||||
|
||||
class Injector
|
||||
{
|
||||
public:
|
||||
typedef AICurlInterface::Responder::buffer_ptr_t buffer_ptr_t;
|
||||
virtual char const* contentType(void) const = 0;
|
||||
virtual U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer) = 0;
|
||||
};
|
||||
|
||||
class LLURLRequest : public AICurlEasyRequestStateMachine {
|
||||
public:
|
||||
@@ -66,7 +75,7 @@ class LLURLRequest : public AICurlEasyRequestStateMachine {
|
||||
* @param action One of the ERequestAction enumerations.
|
||||
* @param url The url of the request. It should already be encoded.
|
||||
*/
|
||||
LLURLRequest(ERequestAction action, std::string const& url);
|
||||
LLURLRequest(ERequestAction action, std::string const& url, Injector* body, AICurlInterface::ResponderPtr responder, AIHTTPHeaders& headers);
|
||||
|
||||
/**
|
||||
* @brief Turn on cookie handling for this request with CURLOPT_COOKIEFILE.
|
||||
@@ -89,33 +98,27 @@ class LLURLRequest : public AICurlEasyRequestStateMachine {
|
||||
*/
|
||||
void addHeader(char const* header);
|
||||
|
||||
/**
|
||||
* @brief Check remote server certificate signed by a known root CA.
|
||||
*
|
||||
* Set whether request will check that remote server
|
||||
* certificates are signed by a known root CA when using HTTPS.
|
||||
*/
|
||||
void checkRootCertificate(bool check);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Handle action specific url request configuration.
|
||||
*
|
||||
* @return Returns true if this is configured.
|
||||
*/
|
||||
bool configure(void);
|
||||
|
||||
/**
|
||||
* @ brief Return the number of bytes to POST or PUT to the server.
|
||||
*
|
||||
* @return Returns the number of bytes we're about to upload.
|
||||
*/
|
||||
S32 bytes_to_send(void) const;
|
||||
bool configure(AICurlEasyRequest_wat const& curlEasyRequest_w);
|
||||
|
||||
private:
|
||||
ERequestAction mAction;
|
||||
std::string mURL;
|
||||
Injector* mBody; // Non-zero iff the action is HTTP_POST and HTTP_PUT.
|
||||
U32 mBodySize;
|
||||
AICurlInterface::ResponderPtr mResponder;
|
||||
AIHTTPHeaders mHeaders;
|
||||
|
||||
protected:
|
||||
// Handle initializing the object.
|
||||
/*virtual*/ void initialize_impl(void);
|
||||
};
|
||||
|
||||
#if 0
|
||||
extern const std::string CONTEXT_REQUEST;
|
||||
extern const std::string CONTEXT_RESPONSE;
|
||||
|
||||
@@ -130,7 +130,7 @@ BOOL FloaterVoiceLicense::postBuild()
|
||||
std::string url = getString( "real_url" );
|
||||
if(url.substr(0,4) == "http") {
|
||||
gResponsePtr = LLIamHereVoice::build( this );
|
||||
LLHTTPClient::get( url, gResponsePtr );
|
||||
LLHTTPClient::get4( url, gResponsePtr );
|
||||
} else {
|
||||
setSiteIsAlive(false);
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ void HGFloaterTextEditor::onClickSave(void* user_data)
|
||||
|
||||
if(caps)
|
||||
{
|
||||
LLHTTPClient::post(url, body,
|
||||
LLHTTPClient::post4(url, body,
|
||||
new LLUpdateAgentInventoryResponder(body, fake_asset_id, item->getType()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include "llhttpclient.h"
|
||||
#include "llurlrequest.h"
|
||||
#include "llxmltree.h"
|
||||
#include "llpumpio.h" // LLPumpIO::chain_t
|
||||
|
||||
#include <curl/curl.h>
|
||||
#ifdef DEBUG_CURLIO
|
||||
@@ -136,40 +135,25 @@ void HippoRestHandlerXml::handle(int status, const std::string &reason,
|
||||
|
||||
// ********************************************************************
|
||||
|
||||
|
||||
class BodyData : public LLIOPipe
|
||||
class BodyDataRaw : public Injector
|
||||
{
|
||||
public:
|
||||
virtual ~BodyData() { }
|
||||
virtual const char *getContentMimeType() const = 0;
|
||||
};
|
||||
|
||||
class BodyDataRaw : public BodyData
|
||||
{
|
||||
public:
|
||||
explicit BodyDataRaw(const std::string &data) :
|
||||
mData(data)
|
||||
{
|
||||
}
|
||||
virtual ~BodyDataRaw() { }
|
||||
explicit BodyDataRaw(const std::string &data) : mData(data) { }
|
||||
|
||||
const char *getContentMimeType() const { return "application/octet-stream"; }
|
||||
/*virtual*/ char const* contentType(void) const { return "application/octet-stream"; }
|
||||
|
||||
EStatus process_impl(const LLChannelDescriptors &channels,
|
||||
buffer_ptr_t &buffer, bool &eos,
|
||||
LLSD &context, LLPumpIO *pump)
|
||||
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
|
||||
{
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
ostream.write(mData.data(), mData.size());
|
||||
eos = true;
|
||||
return STATUS_DONE;
|
||||
return mData.size();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string mData;
|
||||
};
|
||||
|
||||
class BodyDataXml : public BodyData
|
||||
class BodyDataXml : public Injector
|
||||
{
|
||||
public:
|
||||
explicit BodyDataXml(const LLXmlTree *tree) :
|
||||
@@ -182,18 +166,15 @@ class BodyDataXml : public BodyData
|
||||
if (mTree) delete mTree;
|
||||
}
|
||||
|
||||
const char *getContentMimeType() const { return "application/xml"; }
|
||||
/*virtual*/ char const* contentType(void) const { return "application/xml"; }
|
||||
|
||||
EStatus process_impl(const LLChannelDescriptors &channels,
|
||||
buffer_ptr_t &buffer, bool &eos,
|
||||
LLSD &context, LLPumpIO *pump)
|
||||
/*virtual*/ U32 get_body(LLChannelDescriptors const& channels, buffer_ptr_t& buffer)
|
||||
{
|
||||
std::string data;
|
||||
mTree->write(data);
|
||||
LLBufferStream ostream(channels, buffer.get());
|
||||
ostream.write(data.data(), data.size());
|
||||
eos = true;
|
||||
return STATUS_DONE;
|
||||
return data.size();
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -206,40 +187,40 @@ class BodyDataXml : public BodyData
|
||||
|
||||
static void request(const std::string &url,
|
||||
LLURLRequest::ERequestAction method,
|
||||
BodyData *body,
|
||||
Injector *body,
|
||||
HippoRestHandler *handler, float timeout);
|
||||
|
||||
|
||||
// static
|
||||
void HippoRestRequest::get(const std::string &url,
|
||||
void HippoRestRequest::get5(const std::string &url,
|
||||
HippoRestHandler *handler, float timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_GET, 0, handler, timeout);
|
||||
}
|
||||
|
||||
// static
|
||||
void HippoRestRequest::put(const std::string &url, const std::string &body,
|
||||
void HippoRestRequest::put5(const std::string &url, const std::string &body,
|
||||
HippoRestHandler *handler, float timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_PUT, new BodyDataRaw(body), handler, timeout);
|
||||
}
|
||||
|
||||
// static
|
||||
void HippoRestRequest::put(const std::string &url, const LLXmlTree *body,
|
||||
void HippoRestRequest::put5(const std::string &url, const LLXmlTree *body,
|
||||
HippoRestHandler *handler, float timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_PUT, new BodyDataXml(body), handler, timeout);
|
||||
}
|
||||
|
||||
// static
|
||||
void HippoRestRequest::post(const std::string &url, const std::string &body,
|
||||
void HippoRestRequest::post5(const std::string &url, const std::string &body,
|
||||
HippoRestHandler *handler, float timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_POST, new BodyDataRaw(body), handler, timeout);
|
||||
}
|
||||
|
||||
// static
|
||||
void HippoRestRequest::post(const std::string &url, const LLXmlTree *body,
|
||||
void HippoRestRequest::post5(const std::string &url, const LLXmlTree *body,
|
||||
HippoRestHandler *handler, float timeout)
|
||||
{
|
||||
request(url, LLURLRequest::HTTP_POST, new BodyDataXml(body), handler, timeout);
|
||||
@@ -251,27 +232,21 @@ void HippoRestRequest::post(const std::string &url, const LLXmlTree *body,
|
||||
|
||||
static void request(const std::string &url,
|
||||
LLURLRequest::ERequestAction method,
|
||||
BodyData *body,
|
||||
Injector *body,
|
||||
HippoRestHandler *handler, float timeout)
|
||||
{
|
||||
if (!LLHTTPClient::hasPump())
|
||||
{
|
||||
// !!! responder->completed(U32_MAX, "No pump", LLSD());
|
||||
return;
|
||||
}
|
||||
LLPumpIO::chain_t chain;
|
||||
|
||||
LLURLRequest *req;
|
||||
try
|
||||
{
|
||||
req = new LLURLRequest(method, url);
|
||||
AIHTTPHeaders empty_headers;
|
||||
//AIFIXME (doesn't compile): req = new LLURLRequest(method, url, body, handler, empty_headers);
|
||||
}
|
||||
catch(AICurlNoEasyHandle const& error)
|
||||
{
|
||||
llwarns << "Failed to create LLURLRequest: " << error.what() << llendl;
|
||||
return;
|
||||
}
|
||||
req->checkRootCertificate(true);
|
||||
// Already done by default. req->checkRootCertificate(true);
|
||||
|
||||
/*
|
||||
// Insert custom headers if the caller sent any
|
||||
@@ -310,13 +285,13 @@ static void request(const std::string &url,
|
||||
|
||||
if ((method == LLURLRequest::HTTP_PUT) || (method == LLURLRequest::HTTP_POST)) {
|
||||
std::string content = "Content-Type: ";
|
||||
content += body->getContentMimeType();
|
||||
content += body->contentType();
|
||||
req->addHeader(content.c_str());
|
||||
chain.push_back(LLIOPipe::ptr_t(body));
|
||||
//AIFIXME: chain.push_back(LLIOPipe::ptr_t(body));
|
||||
}
|
||||
|
||||
//AIFIXME: chain.push_back(LLIOPipe::ptr_t(req));
|
||||
LLHTTPClient::getPump().addChain(chain, timeout);
|
||||
//LLHTTPClient::getPump().addChain(chain, timeout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef __HIPPO_REST_REQUEST_H__
|
||||
#define __HIPPO_REST_REQUEST_H__
|
||||
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
@@ -11,12 +10,9 @@ class LLBufferArray;
|
||||
class LLChannelDescriptors;
|
||||
class LLXmlTree;
|
||||
|
||||
|
||||
#define HIPPO_REST_TIMEOUT 60.f
|
||||
|
||||
|
||||
// ********************************************************************
|
||||
|
||||
|
||||
class HippoRestHandler
|
||||
{
|
||||
@@ -40,7 +36,6 @@ class HippoRestHandler
|
||||
friend class HippoRestComplete;
|
||||
};
|
||||
|
||||
|
||||
class HippoRestHandlerRaw : public HippoRestHandler
|
||||
{
|
||||
public:
|
||||
@@ -59,7 +54,6 @@ class HippoRestHandlerRaw : public HippoRestHandler
|
||||
const boost::shared_ptr<LLBufferArray> &body);
|
||||
};
|
||||
|
||||
|
||||
class HippoRestHandlerXml : public HippoRestHandler
|
||||
{
|
||||
public:
|
||||
@@ -77,28 +71,25 @@ class HippoRestHandlerXml : public HippoRestHandler
|
||||
const boost::shared_ptr<LLBufferArray> &body);
|
||||
};
|
||||
|
||||
|
||||
// ********************************************************************
|
||||
|
||||
|
||||
class HippoRestRequest
|
||||
{
|
||||
public:
|
||||
// asynchronous interface
|
||||
static void get(const std::string &url,
|
||||
static void get5(const std::string &url,
|
||||
HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT);
|
||||
static void put(const std::string &url, const std::string &body,
|
||||
static void put5(const std::string &url, const std::string &body,
|
||||
HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT);
|
||||
static void put(const std::string &url, const LLXmlTree *body,
|
||||
static void put5(const std::string &url, const LLXmlTree *body,
|
||||
HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT);
|
||||
static void post(const std::string &url, const std::string &body,
|
||||
static void post5(const std::string &url, const std::string &body,
|
||||
HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT);
|
||||
static void post(const std::string &url, const LLXmlTree *body,
|
||||
static void post5(const std::string &url, const LLXmlTree *body,
|
||||
HippoRestHandler *handler, float timeout=HIPPO_REST_TIMEOUT);
|
||||
|
||||
// synchronous interface
|
||||
static int getBlocking(const std::string &url, std::string *result);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
U32 status,
|
||||
const std::string& reason,
|
||||
const LLChannelDescriptors& channels,
|
||||
const LLIOPipe::buffer_ptr_t& buffer);
|
||||
const buffer_ptr_t& buffer);
|
||||
private:
|
||||
lggDicDownloadFloater* panel;
|
||||
std::string name;
|
||||
@@ -131,8 +131,8 @@ void lggDicDownloadFloater::onClickDownload(void* data)
|
||||
if (!comboBox->getSelectedItemLabel().empty())
|
||||
{
|
||||
std::string newDict(self->sNames[comboBox->getCurrentIndex()]);
|
||||
LLHTTPClient::get(gSavedSettings.getString("SpellDownloadURL")+newDict+".aff", new EmeraldDicDownloader(self,newDict+".aff"));
|
||||
LLHTTPClient::get(gSavedSettings.getString("SpellDownloadURL")+newDict+".dic", new EmeraldDicDownloader(NULL,newDict+".dic"));
|
||||
LLHTTPClient::get4(gSavedSettings.getString("SpellDownloadURL")+newDict+".aff", new EmeraldDicDownloader(self,newDict+".aff"));
|
||||
LLHTTPClient::get4(gSavedSettings.getString("SpellDownloadURL")+newDict+".dic", new EmeraldDicDownloader(NULL,newDict+".dic"));
|
||||
|
||||
LLButton* button = self->getChild<LLButton>("Emerald_dic_download");
|
||||
if (button)
|
||||
@@ -163,7 +163,7 @@ EmeraldDicDownloader::EmeraldDicDownloader(lggDicDownloadFloater* spanel, std::s
|
||||
}
|
||||
|
||||
|
||||
void EmeraldDicDownloader::completedRaw(U32 status, const std::string& reason, const LLChannelDescriptors& channels, const LLIOPipe::buffer_ptr_t& buffer)
|
||||
void EmeraldDicDownloader::completedRaw(U32 status, const std::string& reason, const LLChannelDescriptors& channels, const buffer_ptr_t& buffer)
|
||||
{
|
||||
if (status < 200 || status >= 300)
|
||||
{
|
||||
|
||||
@@ -137,7 +137,7 @@ void LLAccountingCostManager::fetchCosts( eSelectionType selectionType, const st
|
||||
LLSD dataToPost = LLSD::emptyMap();
|
||||
dataToPost[keystr.c_str()] = objectList;
|
||||
|
||||
LLHTTPClient::post( url, dataToPost, new LLAccountingCostResponder( objectList ));
|
||||
LLHTTPClient::post4( url, dataToPost, new LLAccountingCostResponder( objectList ));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -2377,7 +2377,7 @@ bool LLAgent::sendMaturityPreferenceToServer(int preferredMaturity)
|
||||
body["access_prefs"] = access_prefs;
|
||||
llinfos << "Sending access prefs update to " << (access_prefs["max"].asString()) << " via capability to: "
|
||||
<< url << llendl;
|
||||
LLHTTPClient::post(url, body, new LLHTTPClient::ResponderIgnore); // Ignore response
|
||||
LLHTTPClient::post4(url, body, new LLHTTPClient::ResponderIgnore); // Ignore response
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -61,7 +61,7 @@ bool LLAgentLanguage::update()
|
||||
body["language"] = language;
|
||||
body["language_is_public"] = gSavedSettings.getBOOL("LanguageIsPublic");
|
||||
|
||||
LLHTTPClient::post(url, body, new LLHTTPClient::ResponderIgnore);
|
||||
LLHTTPClient::post4(url, body, new LLHTTPClient::ResponderIgnore);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1046,7 +1046,6 @@ bool LLAppViewer::mainLoop()
|
||||
|
||||
// Create IO Pump to use for HTTP Requests.
|
||||
gServicePump = new LLPumpIO;
|
||||
LLHTTPClient::setPump(*gServicePump);
|
||||
LLCurl::setCAFile(gDirUtilp->getCAFile());
|
||||
|
||||
// Note: this is where gLocalSpeakerMgr and gActiveSpeakerMgr used to be instantiated.
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
LLAssetUploadChainResponder(const LLSD& post_data,
|
||||
const std::string& file_name,
|
||||
const LLUUID& queue_id,
|
||||
U8* data,
|
||||
char* data,
|
||||
U32 data_size,
|
||||
std::string script_name,
|
||||
LLAssetUploadQueueSupplier *supplier) :
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
llinfos << "Compiling " << llendl;
|
||||
|
||||
// postRaw takes ownership of mData and will delete it.
|
||||
LLHTTPClient::postRaw(uploader, mData, mDataSize, this);
|
||||
LLHTTPClient::postRaw4(uploader, mData, mDataSize, this);
|
||||
mData = NULL;
|
||||
mDataSize = 0;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public:
|
||||
}
|
||||
|
||||
LLAssetUploadQueueSupplier *mSupplier;
|
||||
U8* mData;
|
||||
char* mData;
|
||||
U32 mDataSize;
|
||||
std::string mScriptName;
|
||||
};
|
||||
@@ -174,7 +174,7 @@ void LLAssetUploadQueue::request(LLAssetUploadQueueSupplier** supplier)
|
||||
if (object)
|
||||
{
|
||||
url = object->getRegion()->getCapability("UpdateScriptTask");
|
||||
LLHTTPClient::post(url, body,
|
||||
LLHTTPClient::post4(url, body,
|
||||
new LLAssetUploadChainResponder(
|
||||
body, data.mFilename, data.mQueueId,
|
||||
data.mData, data.mDataSize, data.mScriptName, *supplier));
|
||||
@@ -189,7 +189,7 @@ void LLAssetUploadQueue::queue(const std::string& filename,
|
||||
BOOL is_running,
|
||||
BOOL is_target_mono,
|
||||
const LLUUID& queue_id,
|
||||
U8* script_data,
|
||||
char* script_data,
|
||||
U32 data_size,
|
||||
std::string script_name)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
BOOL is_running,
|
||||
BOOL is_target_mono,
|
||||
const LLUUID& queue_id,
|
||||
U8* data,
|
||||
char* data,
|
||||
U32 data_size,
|
||||
std::string script_name);
|
||||
|
||||
@@ -72,7 +72,7 @@ private:
|
||||
BOOL mIsRunning;
|
||||
BOOL mIsTargetMono;
|
||||
LLUUID mQueueId;
|
||||
U8* mData;
|
||||
char* mData;
|
||||
U32 mDataSize;
|
||||
std::string mScriptName;
|
||||
};
|
||||
|
||||
@@ -283,11 +283,11 @@ void LLAssetUploadResponder::uploadUpload(const LLSD& content)
|
||||
std::string uploader = content["uploader"];
|
||||
if (mFileName.empty())
|
||||
{
|
||||
LLHTTPClient::postFile(uploader, mVFileID, mAssetType, this);
|
||||
LLHTTPClient::postFile4(uploader, mVFileID, mAssetType, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
LLHTTPClient::postFile(uploader, mFileName, this);
|
||||
LLHTTPClient::postFile4(uploader, mFileName, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -946,7 +946,7 @@ public:
|
||||
if ( getFilename().empty() )
|
||||
{
|
||||
// we have no filename, use virtual file ID instead
|
||||
LLHTTPClient::postFile(
|
||||
LLHTTPClient::postFile4(
|
||||
confirmation_url,
|
||||
getVFileID(),
|
||||
getAssetType(),
|
||||
@@ -954,7 +954,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
LLHTTPClient::postFile(
|
||||
LLHTTPClient::postFile4(
|
||||
confirmation_url,
|
||||
getFilename(),
|
||||
responder);
|
||||
|
||||
@@ -106,12 +106,11 @@ bool LLCapabilityListener::capListener(const LLSD& request)
|
||||
if (! url.empty())
|
||||
{
|
||||
// This capability is supported by the region to which we're talking.
|
||||
LLHTTPClient::post(url, payload,
|
||||
LLHTTPClient::post4(url, payload,
|
||||
new LLSDMessage::EventResponder(LLEventPumps::instance(),
|
||||
request,
|
||||
mProvider.getDescription(),
|
||||
cap, reply, error),
|
||||
LLSD(), // headers
|
||||
timeout);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -50,5 +50,5 @@ void LLCapHTTPSender::send(const LLHost& host, const std::string& message,
|
||||
LLSD llsd;
|
||||
llsd["message"] = message;
|
||||
llsd["body"] = body;
|
||||
LLHTTPClient::post(mCap, llsd, response);
|
||||
LLHTTPClient::post4(mCap, llsd, response);
|
||||
}
|
||||
|
||||
@@ -437,8 +437,8 @@ void LLFloaterCompileQueue::scriptArrived(LLVFS *vfs, const LLUUID& asset_id,
|
||||
{
|
||||
// Read script source in to buffer.
|
||||
U32 script_size = file.getSize();
|
||||
U8* script_data = new U8[script_size];
|
||||
file.read(script_data, script_size);
|
||||
char* script_data = new char[script_size];
|
||||
file.read(reinterpret_cast<U8*>(script_data), script_size);
|
||||
|
||||
queue->mUploadQueue->queue(filename, data->mTaskId,
|
||||
data->mItemId, is_running, queue->mMono, queue->getID(),
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace
|
||||
virtual void completedRaw(U32 status,
|
||||
const std::string& reason,
|
||||
const LLChannelDescriptors& channels,
|
||||
const LLIOPipe::buffer_ptr_t& buffer);
|
||||
const buffer_ptr_t& buffer);
|
||||
private:
|
||||
|
||||
bool mDone;
|
||||
@@ -160,7 +160,7 @@ namespace
|
||||
void LLEventPollResponder::completedRaw(U32 status,
|
||||
const std::string& reason,
|
||||
const LLChannelDescriptors& channels,
|
||||
const LLIOPipe::buffer_ptr_t& buffer)
|
||||
const buffer_ptr_t& buffer)
|
||||
{
|
||||
if (status == HTTP_BAD_GATEWAY)
|
||||
{
|
||||
@@ -182,7 +182,7 @@ namespace
|
||||
|
||||
lldebugs << "LLEventPollResponder::makeRequest <" << mCount << "> ack = "
|
||||
<< LLSDXMLStreamer(mAcknowledge) << llendl;
|
||||
LLHTTPClient::post(mPollURL, request, this);
|
||||
LLHTTPClient::post4(mPollURL, request, this);
|
||||
}
|
||||
|
||||
void LLEventPollResponder::handleMessage(const LLSD& content)
|
||||
|
||||
@@ -888,7 +888,7 @@ void LLPanelActiveSpeakers::onModeratorMuteVoice(LLUICtrl* ctrl, void* user_data
|
||||
LLUUID mSessionID;
|
||||
};
|
||||
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
data,
|
||||
new MuteVoiceResponder(self->mSpeakerMgr->getSessionID()));
|
||||
@@ -953,7 +953,7 @@ void LLPanelActiveSpeakers::onModeratorMuteText(LLUICtrl* ctrl, void* user_data)
|
||||
LLUUID mSessionID;
|
||||
};
|
||||
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
data,
|
||||
new MuteTextResponder(self->mSpeakerMgr->getSessionID()));
|
||||
@@ -991,7 +991,7 @@ void LLPanelActiveSpeakers::onChangeModerationMode(LLUICtrl* ctrl, void* user_da
|
||||
}
|
||||
};
|
||||
|
||||
LLHTTPClient::post(url, data, new ModerationModeResponder());
|
||||
LLHTTPClient::post4(url, data, new ModerationModeResponder());
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -53,7 +53,7 @@ void LLFloaterModelUploadBase::requestAgentUploadPermissions()
|
||||
if (!url.empty())
|
||||
{
|
||||
llinfos<< typeid(*this).name() <<"::requestAgentUploadPermissions() requesting for upload model permissions from: "<< url <<llendl;
|
||||
LLHTTPClient::get(url, new LLUploadModelPremissionsResponder(getPermObserverHandle()));
|
||||
LLHTTPClient::get4(url, new LLUploadModelPremissionsResponder(getPermObserverHandle()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -396,7 +396,7 @@ void LLFloaterPostcard::sendPostcard()
|
||||
body["name"] = childGetValue("name_form").asString();
|
||||
body["subject"] = childGetValue("subject_form").asString();
|
||||
body["msg"] = childGetValue("msg_form").asString();
|
||||
LLHTTPClient::post(url, body, new LLSendPostcardResponder(body, mAssetID, LLAssetType::AT_IMAGE_JPEG));
|
||||
LLHTTPClient::post4(url, body, new LLSendPostcardResponder(body, mAssetID, LLAssetType::AT_IMAGE_JPEG));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -208,7 +208,7 @@ void LLFloaterRegionDebugConsole::onInput(LLUICtrl* ctrl, const LLSD& param)
|
||||
else
|
||||
{
|
||||
// Using SimConsole (deprecated)
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
LLSD(input->getText()),
|
||||
new ConsoleResponder(mOutput));
|
||||
@@ -217,7 +217,7 @@ void LLFloaterRegionDebugConsole::onInput(LLUICtrl* ctrl, const LLSD& param)
|
||||
else
|
||||
{
|
||||
// Using SimConsoleAsync
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
LLSD(input->getText()),
|
||||
new AsyncConsoleResponder);
|
||||
|
||||
@@ -760,7 +760,7 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate()
|
||||
body["allow_parcel_changes"] = childGetValue("allow_parcel_changes_check");
|
||||
body["block_parcel_search"] = childGetValue("block_parcel_search_check");
|
||||
|
||||
LLHTTPClient::post(url, body, new LLHTTPClient::ResponderIgnore);
|
||||
LLHTTPClient::post4(url, body, new LLHTTPClient::ResponderIgnore);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2356,7 +2356,7 @@ bool LLPanelEstateInfo::commitEstateInfoCaps()
|
||||
body["owner_abuse_email"] = childGetValue("abuse_email_address").asString();
|
||||
|
||||
// we use a responder so that we can re-get the data after committing to the database
|
||||
LLHTTPClient::post(url, body, new LLEstateChangeInfoResponder((void*)this));
|
||||
LLHTTPClient::post4(url, body, new LLEstateChangeInfoResponder((void*)this));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -877,14 +877,14 @@ void LLFloaterReporter::sendReportViaCaps(std::string url, std::string sshot_url
|
||||
if(childGetValue("screen_check").asBoolean() && !sshot_url.empty())
|
||||
{
|
||||
// try to upload screenshot
|
||||
LLHTTPClient::post(sshot_url, report, new LLUserReportScreenshotResponder(report,
|
||||
LLHTTPClient::post4(sshot_url, report, new LLUserReportScreenshotResponder(report,
|
||||
mResourceDatap->mAssetInfo.mUuid,
|
||||
mResourceDatap->mAssetInfo.mType));
|
||||
}
|
||||
else
|
||||
{
|
||||
// screenshot not wanted or we don't have screenshot cap
|
||||
LLHTTPClient::post(url, report, new LLUserReportResponder());
|
||||
LLHTTPClient::post4(url, report, new LLUserReportResponder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ void LLFloaterTeleport::onClickTeleport(void* userdata)
|
||||
args["public_region_seed_capability"] = text;
|
||||
args["position"] = ll_sd_from_vector3(LLVector3(128, 128, 50)); // default to middle of region above base terrain
|
||||
LL_INFOS("OGPX") << " args to placeavatar cap " << placeAvatarCap << " on teleport: " << LLSDOStreamer<LLSDXMLFormatter>(args) << LL_ENDL;
|
||||
LLHTTPClient::post(placeAvatarCap, args, new LLPlaceAvatarTeleportResponder());
|
||||
LLHTTPClient::post4(placeAvatarCap, args, new LLPlaceAvatarTeleportResponder());
|
||||
gAgent.setTeleportMessage(
|
||||
LLAgent::sTeleportProgressMessages["requesting"]);
|
||||
gViewerWindow->setShowProgress(TRUE);
|
||||
|
||||
@@ -167,7 +167,7 @@ BOOL LLFloaterTOS::postBuild()
|
||||
{
|
||||
web_browser->addObserver(this);
|
||||
gResponsePtr = LLIamHere::build( this );
|
||||
LLHTTPClient::get( getString( "real_url" ), gResponsePtr );
|
||||
LLHTTPClient::get4( getString( "real_url" ), gResponsePtr );
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
@@ -231,7 +231,7 @@ void LLFloaterURLEntry::onBtnOK( void* userdata )
|
||||
// Discover the MIME type only for "http" scheme.
|
||||
if(scheme == "http" || scheme == "https")
|
||||
{
|
||||
LLHTTPClient::getHeaderOnly( media_url,
|
||||
LLHTTPClient::getHeaderOnly4( media_url,
|
||||
new LLMediaTypeResponder(self->getHandle()));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -271,7 +271,7 @@ bool send_start_session_messages(
|
||||
|
||||
data["params"] = agents;
|
||||
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
data,
|
||||
new LLStartConferenceChatResponder(
|
||||
@@ -715,7 +715,7 @@ void LLVoiceChannelGroup::getChannelInfo()
|
||||
LLSD data;
|
||||
data["method"] = "call";
|
||||
data["session-id"] = mSessionID;
|
||||
LLHTTPClient::post(url,
|
||||
LLHTTPClient::post4(url,
|
||||
data,
|
||||
new LLVoiceCallCapResponder(mSessionID));
|
||||
}
|
||||
@@ -1593,7 +1593,7 @@ BOOL LLFloaterIMPanel::inviteToSession(const LLDynamicArray<LLUUID>& ids)
|
||||
|
||||
data["method"] = "invite";
|
||||
data["session-id"] = mSessionUUID;
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
data,
|
||||
new LLSessionInviteResponder(
|
||||
|
||||
@@ -400,7 +400,7 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response)
|
||||
LLSD data;
|
||||
data["method"] = "accept invitation";
|
||||
data["session-id"] = session_id;
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
data,
|
||||
new LLViewerChatterBoxInvitationAcceptResponder(
|
||||
@@ -438,7 +438,7 @@ bool inviteUserResponse(const LLSD& notification, const LLSD& response)
|
||||
LLSD data;
|
||||
data["method"] = "decline invitation";
|
||||
data["session-id"] = session_id;
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
data,
|
||||
NULL);
|
||||
@@ -1720,7 +1720,7 @@ public:
|
||||
LLSD data;
|
||||
data["method"] = "accept invitation";
|
||||
data["session-id"] = session_id;
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
data,
|
||||
new LLViewerChatterBoxInvitationAcceptResponder(
|
||||
|
||||
@@ -572,7 +572,7 @@ LLUUID LLInventoryModel::createNewCategory(const LLUUID& parent_id,
|
||||
request["payload"] = body;
|
||||
|
||||
// viewer_region->getCapAPI().post(request);
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
body,
|
||||
new LLCreateInventoryCategoryResponder(this, callback, user_data) );
|
||||
|
||||
@@ -699,14 +699,14 @@ void LLInventoryModelBackgroundFetch::bulkFetch()
|
||||
if (folder_request_body["folders"].size())
|
||||
{
|
||||
LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(folder_request_body, recursive_cats);
|
||||
LLHTTPClient::post(url, folder_request_body, fetcher, 300.0);
|
||||
LLHTTPClient::post4(url, folder_request_body, fetcher, 300.0);
|
||||
}
|
||||
if (folder_request_body_lib["folders"].size())
|
||||
{
|
||||
std::string url_lib = gAgent.getRegion()->getCapability("FetchLibDescendents2");
|
||||
|
||||
LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(folder_request_body_lib, recursive_cats);
|
||||
LLHTTPClient::post(url_lib, folder_request_body_lib, fetcher, 300.0);
|
||||
LLHTTPClient::post4(url_lib, folder_request_body_lib, fetcher, 300.0);
|
||||
}
|
||||
}
|
||||
if (item_count)
|
||||
@@ -723,7 +723,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch()
|
||||
body["agent_id"] = gAgent.getID();
|
||||
body["items"] = item_request_body;
|
||||
|
||||
LLHTTPClient::post(url, body, new LLInventoryModelFetchItemResponder(body));
|
||||
LLHTTPClient::post4(url, body, new LLInventoryModelFetchItemResponder(body));
|
||||
}
|
||||
//else
|
||||
//{
|
||||
@@ -750,7 +750,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch()
|
||||
body["agent_id"] = gAgent.getID();
|
||||
body["items"] = item_request_body_lib;
|
||||
|
||||
LLHTTPClient::post(url, body, new LLInventoryModelFetchItemResponder(body));
|
||||
LLHTTPClient::post4(url, body, new LLInventoryModelFetchItemResponder(body));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ void fetch_items_from_llsd(const LLSD& items_llsd)
|
||||
if (!url.empty())
|
||||
{
|
||||
body[i]["agent_id"] = gAgent.getID();
|
||||
LLHTTPClient::post(url, body[i], new LLInventoryModel::fetchInventoryResponder(body[i]));
|
||||
LLHTTPClient::post4(url, body[i], new LLInventoryModel::fetchInventoryResponder(body[i]));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -766,14 +766,13 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id)
|
||||
}
|
||||
|
||||
//reading from VFS failed for whatever reason, fetch from sim
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("Accept: application/octet-stream");
|
||||
AIHTTPHeaders headers("Accept", "application/octet-stream");
|
||||
|
||||
std::string http_url = constructUrl(mesh_id);
|
||||
if (!http_url.empty())
|
||||
{
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
mCurlRequest->getByteRange(http_url, headers, offset, size,
|
||||
mCurlRequest->getByteRange2(http_url, headers, offset, size,
|
||||
new LLMeshSkinInfoResponder(mesh_id, offset, size));
|
||||
LLMeshRepository::sHTTPRequestCount++;
|
||||
}
|
||||
@@ -841,14 +840,13 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id)
|
||||
}
|
||||
|
||||
//reading from VFS failed for whatever reason, fetch from sim
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("Accept: application/octet-stream");
|
||||
AIHTTPHeaders headers("Accept", "application/octet-stream");
|
||||
|
||||
std::string http_url = constructUrl(mesh_id);
|
||||
if (!http_url.empty())
|
||||
{
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
mCurlRequest->getByteRange(http_url, headers, offset, size,
|
||||
mCurlRequest->getByteRange2(http_url, headers, offset, size,
|
||||
new LLMeshDecompositionResponder(mesh_id, offset, size));
|
||||
LLMeshRepository::sHTTPRequestCount++;
|
||||
}
|
||||
@@ -916,14 +914,13 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id)
|
||||
}
|
||||
|
||||
//reading from VFS failed for whatever reason, fetch from sim
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("Accept: application/octet-stream");
|
||||
AIHTTPHeaders headers("Accept", "application/octet-stream");
|
||||
|
||||
std::string http_url = constructUrl(mesh_id);
|
||||
if (!http_url.empty())
|
||||
{
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
mCurlRequest->getByteRange(http_url, headers, offset, size,
|
||||
mCurlRequest->getByteRange2(http_url, headers, offset, size,
|
||||
new LLMeshPhysicsShapeResponder(mesh_id, offset, size));
|
||||
LLMeshRepository::sHTTPRequestCount++;
|
||||
}
|
||||
@@ -966,8 +963,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, U32& c
|
||||
}
|
||||
|
||||
//either cache entry doesn't exist or is corrupt, request header from simulator
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("Accept: application/octet-stream");
|
||||
AIHTTPHeaders headers("Accept", "application/octet-stream");
|
||||
|
||||
std::string http_url = constructUrl(mesh_params.getSculptID());
|
||||
if (!http_url.empty())
|
||||
@@ -976,7 +972,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params, U32& c
|
||||
//within the first 4KB
|
||||
//NOTE -- this will break of headers ever exceed 4KB
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
mCurlRequest->getByteRange(http_url, headers, 0, 4096, new LLMeshHeaderResponder(mesh_params));
|
||||
mCurlRequest->getByteRange2(http_url, headers, 0, 4096, new LLMeshHeaderResponder(mesh_params));
|
||||
LLMeshRepository::sHTTPRequestCount++;
|
||||
count++;
|
||||
}
|
||||
@@ -1031,14 +1027,13 @@ void LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod,
|
||||
}
|
||||
|
||||
//reading from VFS failed for whatever reason, fetch from sim
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("Accept: application/octet-stream");
|
||||
AIHTTPHeaders headers("Accept", "application/octet-stream");
|
||||
|
||||
std::string http_url = constructUrl(mesh_id);
|
||||
if (!http_url.empty())
|
||||
{
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
mCurlRequest->getByteRange(constructUrl(mesh_id), headers, offset, size,
|
||||
mCurlRequest->getByteRange2(constructUrl(mesh_id), headers, offset, size,
|
||||
new LLMeshLODResponder(mesh_params, lod, offset, size));
|
||||
LLMeshRepository::sHTTPRequestCount++;
|
||||
count++;
|
||||
@@ -1612,9 +1607,9 @@ void LLMeshUploadThread::doWholeModelUpload()
|
||||
wholeModelToLLSD(full_model_data, true);
|
||||
LLSD body = full_model_data["asset_resources"];
|
||||
dump_llsd_to_file(body,make_dump_name("whole_model_body_",dump_num));
|
||||
LLCurlRequest::headers_t headers;
|
||||
AIHTTPHeaders headers;
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
mCurlRequest->post(mWholeModelUploadURL, headers, body,
|
||||
mCurlRequest->post2(mWholeModelUploadURL, headers, body,
|
||||
new LLWholeModelUploadResponder(this, full_model_data, mUploadObserverHandle), mMeshUploadTimeOut);
|
||||
do
|
||||
{
|
||||
@@ -1646,9 +1641,9 @@ void LLMeshUploadThread::requestWholeModelFee()
|
||||
dump_llsd_to_file(model_data,make_dump_name("whole_model_fee_request_",dump_num));
|
||||
|
||||
mPendingUploads++;
|
||||
LLCurlRequest::headers_t headers;
|
||||
AIHTTPHeaders headers;
|
||||
// This might throw AICurlNoEasyHandle.
|
||||
mCurlRequest->post(mWholeModelFeeCapability, headers, model_data,
|
||||
mCurlRequest->post2(mWholeModelFeeCapability, headers, model_data,
|
||||
new LLWholeModelFeeResponder(this,model_data, mFeeObserverHandle), mMeshUploadTimeOut);
|
||||
|
||||
do
|
||||
|
||||
@@ -587,7 +587,7 @@ void LLPanelClassified::sendClassifiedInfoRequest()
|
||||
if (!url.empty())
|
||||
{
|
||||
llinfos << "Classified stat request via capability" << llendl;
|
||||
LLHTTPClient::post(url, body, new LLClassifiedStatsResponder(((LLView*)this)->getHandle(), mClassifiedID));
|
||||
LLHTTPClient::post4(url, body, new LLClassifiedStatsResponder(((LLView*)this)->getHandle(), mClassifiedID));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -999,7 +999,7 @@ void LLPanelClassified::sendClassifiedClickMessage(const std::string& type)
|
||||
|
||||
std::string url = gAgent.getRegion()->getCapability("SearchStatTracking");
|
||||
llinfos << "LLPanelClassified::sendClassifiedClickMessage via capability" << llendl;
|
||||
LLHTTPClient::post(url, body, new LLHTTPClient::ResponderIgnore);
|
||||
LLHTTPClient::post4(url, body, new LLHTTPClient::ResponderIgnore);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -778,7 +778,7 @@ void LLPanelGroupVoting::impl::sendStartGroupProposal()
|
||||
body["duration"] = duration_seconds;
|
||||
body["proposal-text"] = mProposalText->getText();
|
||||
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
body,
|
||||
new LLStartGroupVoteResponder(mGroupID),
|
||||
@@ -825,7 +825,7 @@ void LLPanelGroupVoting::impl::sendGroupProposalBallot(const std::string& vote)
|
||||
body["group-id"] = mGroupID;
|
||||
body["vote"] = vote;
|
||||
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
body,
|
||||
new LLGroupProposalBallotResponder(mGroupID),
|
||||
|
||||
@@ -892,7 +892,7 @@ void LLPanelLogin::refreshLoginPage()
|
||||
|
||||
std::string login_page = gHippoGridManager->getConnectedGrid()->getLoginPage();
|
||||
if (!login_page.empty()) {
|
||||
LLHTTPClient::head(login_page, gResponsePtr);
|
||||
LLHTTPClient::head4(login_page, gResponsePtr);
|
||||
} else {
|
||||
sInstance->setSiteIsAlive(false);
|
||||
}
|
||||
|
||||
@@ -391,7 +391,7 @@ void LLPanelPlace::displayParcelInfo(const LLVector3& pos_region,
|
||||
U64 region_handle = to_region_handle(pos_global);
|
||||
body["region_handle"] = ll_sd_from_U64(region_handle);
|
||||
}
|
||||
LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(this->getHandle()));
|
||||
LLHTTPClient::post4(url, body, new LLRemoteParcelRequestResponder(this->getHandle()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -364,7 +364,7 @@ void LLPathfindingManager::requestGetNavMeshForRegion(LLViewerRegion *pRegion, b
|
||||
llassert(!navMeshStatusURL.empty());
|
||||
navMeshPtr->handleNavMeshCheckVersion();
|
||||
LLHTTPClient::ResponderPtr navMeshStatusResponder = new NavMeshStatusResponder(navMeshStatusURL, pRegion, pIsGetStatusOnly);
|
||||
LLHTTPClient::get(navMeshStatusURL, navMeshStatusResponder);
|
||||
LLHTTPClient::get4(navMeshStatusURL, navMeshStatusResponder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,12 +398,12 @@ void LLPathfindingManager::requestGetLinksets(request_id_t pRequestId, object_re
|
||||
LinksetsResponderPtr linksetsResponderPtr(new LinksetsResponder(pRequestId, pLinksetsCallback, true, doRequestTerrain));
|
||||
|
||||
LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr);
|
||||
LLHTTPClient::get(objectLinksetsURL, objectLinksetsResponder);
|
||||
LLHTTPClient::get4(objectLinksetsURL, objectLinksetsResponder);
|
||||
|
||||
if (doRequestTerrain)
|
||||
{
|
||||
LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr);
|
||||
LLHTTPClient::get(terrainLinksetsURL, terrainLinksetsResponder);
|
||||
LLHTTPClient::get4(terrainLinksetsURL, terrainLinksetsResponder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -447,13 +447,13 @@ void LLPathfindingManager::requestSetLinksets(request_id_t pRequestId, const LLP
|
||||
if (!objectPostData.isUndefined())
|
||||
{
|
||||
LLHTTPClient::ResponderPtr objectLinksetsResponder = new ObjectLinksetsResponder(objectLinksetsURL, linksetsResponderPtr);
|
||||
LLHTTPClient::put(objectLinksetsURL, objectPostData, objectLinksetsResponder);
|
||||
LLHTTPClient::put4(objectLinksetsURL, objectPostData, objectLinksetsResponder);
|
||||
}
|
||||
|
||||
if (!terrainPostData.isUndefined())
|
||||
{
|
||||
LLHTTPClient::ResponderPtr terrainLinksetsResponder = new TerrainLinksetsResponder(terrainLinksetsURL, linksetsResponderPtr);
|
||||
LLHTTPClient::put(terrainLinksetsURL, terrainPostData, terrainLinksetsResponder);
|
||||
LLHTTPClient::put4(terrainLinksetsURL, terrainPostData, terrainLinksetsResponder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -486,7 +486,7 @@ void LLPathfindingManager::requestGetCharacters(request_id_t pRequestId, object_
|
||||
pCharactersCallback(pRequestId, kRequestStarted, emptyCharacterListPtr);
|
||||
|
||||
LLHTTPClient::ResponderPtr charactersResponder = new CharactersResponder(charactersURL, pRequestId, pCharactersCallback);
|
||||
LLHTTPClient::get(charactersURL, charactersResponder);
|
||||
LLHTTPClient::get4(charactersURL, charactersResponder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -519,7 +519,7 @@ void LLPathfindingManager::requestGetAgentState()
|
||||
std::string agentStateURL = getAgentStateURLForRegion(currentRegion);
|
||||
llassert(!agentStateURL.empty());
|
||||
LLHTTPClient::ResponderPtr responder = new AgentStateResponder(agentStateURL);
|
||||
LLHTTPClient::get(agentStateURL, responder);
|
||||
LLHTTPClient::get4(agentStateURL, responder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,7 +543,7 @@ void LLPathfindingManager::requestRebakeNavMesh(rebake_navmesh_callback_t pRebak
|
||||
LLSD postData;
|
||||
postData["command"] = "rebuild";
|
||||
LLHTTPClient::ResponderPtr responder = new NavMeshRebakeResponder(navMeshStatusURL, pRebakeNavMeshCallback);
|
||||
LLHTTPClient::post(navMeshStatusURL, postData, responder);
|
||||
LLHTTPClient::post4(navMeshStatusURL, postData, responder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -567,7 +567,7 @@ void LLPathfindingManager::sendRequestGetNavMeshForRegion(LLPathfindingNavMeshPt
|
||||
LLHTTPClient::ResponderPtr responder = new NavMeshResponder(navMeshURL, pNavMeshStatus.getVersion(), navMeshPtr);
|
||||
|
||||
LLSD postData;
|
||||
LLHTTPClient::post(navMeshURL, postData, responder);
|
||||
LLHTTPClient::post4(navMeshURL, postData, responder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1183,7 +1183,7 @@ void LLPreviewGesture::saveIfNeeded()
|
||||
// Saving into agent inventory
|
||||
LLSD body;
|
||||
body["item_id"] = mItemUUID;
|
||||
LLHTTPClient::post(agent_url, body,
|
||||
LLHTTPClient::post4(agent_url, body,
|
||||
new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE));
|
||||
delayedUpload = TRUE;
|
||||
}
|
||||
@@ -1193,7 +1193,7 @@ void LLPreviewGesture::saveIfNeeded()
|
||||
LLSD body;
|
||||
body["task_id"] = mObjectUUID;
|
||||
body["item_id"] = mItemUUID;
|
||||
LLHTTPClient::post(task_url, body,
|
||||
LLHTTPClient::post4(task_url, body,
|
||||
new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_GESTURE));
|
||||
}
|
||||
else if (gAssetStorage)
|
||||
|
||||
@@ -569,7 +569,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
|
||||
body["item_id"] = mItemUUID;
|
||||
llinfos << "Saving notecard " << mItemUUID
|
||||
<< " into agent inventory via " << agent_url << llendl;
|
||||
LLHTTPClient::post(agent_url, body,
|
||||
LLHTTPClient::post4(agent_url, body,
|
||||
new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
|
||||
}
|
||||
else if (!mObjectUUID.isNull() && !task_url.empty())
|
||||
@@ -582,7 +582,7 @@ bool LLPreviewNotecard::saveIfNeeded(LLInventoryItem* copyitem)
|
||||
body["item_id"] = mItemUUID;
|
||||
llinfos << "Saving notecard " << mItemUUID << " into task "
|
||||
<< mObjectUUID << " via " << task_url << llendl;
|
||||
LLHTTPClient::post(task_url, body,
|
||||
LLHTTPClient::post4(task_url, body,
|
||||
new LLUpdateTaskInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
|
||||
}
|
||||
else if (gAssetStorage)
|
||||
|
||||
@@ -1494,7 +1494,7 @@ void LLPreviewLSL::uploadAssetViaCaps(const std::string& url,
|
||||
{
|
||||
body["target"] = "lsl2";
|
||||
}
|
||||
LLHTTPClient::post(url, body, new LLUpdateAgentInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT));
|
||||
LLHTTPClient::post4(url, body, new LLUpdateAgentInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT));
|
||||
}
|
||||
|
||||
void LLPreviewLSL::uploadAssetLegacy(const std::string& filename,
|
||||
@@ -2393,7 +2393,7 @@ void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url,
|
||||
body["item_id"] = item_id;
|
||||
body["is_script_running"] = is_running;
|
||||
body["target"] = monoChecked() ? "mono" : "lsl2";
|
||||
LLHTTPClient::post(url, body,
|
||||
LLHTTPClient::post4(url, body,
|
||||
new LLUpdateTaskInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT));
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ void LLProductInfoRequestManager::initSingleton()
|
||||
std::string url = gAgent.getRegion()->getCapability("ProductInfoRequest");
|
||||
if (!url.empty())
|
||||
{
|
||||
LLHTTPClient::get(url, new LLProductInfoRequestResponder());
|
||||
LLHTTPClient::get4(url, new LLProductInfoRequestResponder());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -541,7 +541,7 @@ void LLTexLayerSetBuffer::doUpload()
|
||||
{
|
||||
LLSD body = LLSD::emptyMap();
|
||||
// The responder will call LLTexLayerSetBuffer::onTextureUploadComplete()
|
||||
LLHTTPClient::post(url, body, new LLSendTexLayerResponder(body, mUploadID, LLAssetType::AT_TEXTURE, baked_upload_data));
|
||||
LLHTTPClient::post4(url, body, new LLSendTexLayerResponder(body, mUploadID, LLAssetType::AT_TEXTURE, baked_upload_data));
|
||||
llinfos << "Baked texture upload via capability of " << mUploadID << " to " << url << llendl;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
// void relese() { --mActiveCount; }
|
||||
|
||||
S32 callbackHttpGet(const LLChannelDescriptors& channels,
|
||||
const LLIOPipe::buffer_ptr_t& buffer,
|
||||
const LLHTTPClient::Responder::buffer_ptr_t& buffer,
|
||||
bool partial, bool success);
|
||||
void callbackCacheRead(bool success, LLImageFormatted* image,
|
||||
S32 imagesize, BOOL islocal);
|
||||
@@ -303,7 +303,7 @@ public:
|
||||
|
||||
virtual void completedRaw(U32 status, const std::string& reason,
|
||||
const LLChannelDescriptors& channels,
|
||||
const LLIOPipe::buffer_ptr_t& buffer)
|
||||
const buffer_ptr_t& buffer)
|
||||
{
|
||||
static LLCachedControl<bool> log_to_viewer_log(gSavedSettings,"LogTextureDownloadsToViewerLog");
|
||||
static LLCachedControl<bool> log_to_sim(gSavedSettings,"LogTextureDownloadsToSimulator");
|
||||
@@ -1319,11 +1319,10 @@ bool LLTextureFetchWorker::doWork(S32 param)
|
||||
#endif
|
||||
|
||||
// Will call callbackHttpGet when curl request completes
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("Accept: image/x-j2c");
|
||||
AIHTTPHeaders headers("Accept", "image/x-j2c");
|
||||
try
|
||||
{
|
||||
res = mFetcher->mCurlGetRequest->getByteRange(mUrl, headers, offset, mRequestedSize,
|
||||
res = mFetcher->mCurlGetRequest->getByteRange2(mUrl, headers, offset, mRequestedSize,
|
||||
new HTTPGetResponder(mFetcher, mID, LLTimer::getTotalTime(), mRequestedSize, offset, true));
|
||||
}
|
||||
catch(AICurlNoEasyHandle const& error)
|
||||
@@ -1806,7 +1805,7 @@ bool LLTextureFetchWorker::processSimulatorPackets()
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
S32 LLTextureFetchWorker::callbackHttpGet(const LLChannelDescriptors& channels,
|
||||
const LLIOPipe::buffer_ptr_t& buffer,
|
||||
const LLHTTPClient::Responder::buffer_ptr_t& buffer,
|
||||
bool partial, bool success)
|
||||
{
|
||||
S32 data_size = 0 ;
|
||||
|
||||
@@ -47,7 +47,7 @@ void LLTextureStatsUploader::uploadStatsToSimulator(const std::string texture_ca
|
||||
{
|
||||
if ( texture_cap_url != "" )
|
||||
{
|
||||
LLHTTPClient::post(texture_cap_url, texture_stats, NULL);
|
||||
LLHTTPClient::post4(texture_cap_url, texture_stats, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -47,7 +47,7 @@ const char* LLTranslate::m_GoogleURL = "http://ajax.googleapis.com/ajax/services
|
||||
const char* LLTranslate::m_GoogleLangSpec = "&langpair=";
|
||||
float LLTranslate::m_GoogleTimeout = 10;
|
||||
|
||||
LLSD LLTranslate::m_Header;
|
||||
AIHTTPHeaders LLTranslate::m_Header;
|
||||
// These constants are for the GET header.
|
||||
const char* LLTranslate::m_AcceptHeader = "Accept";
|
||||
const char* LLTranslate::m_AcceptType = "text/plain";
|
||||
@@ -68,13 +68,13 @@ void LLTranslate::translateMessage(LLHTTPClient::ResponderPtr &result, const std
|
||||
std::string user_agent = gCurrentVersion;
|
||||
//</edit>
|
||||
|
||||
if (!m_Header.size())
|
||||
if (m_Header.empty())
|
||||
{
|
||||
m_Header.insert(m_AcceptHeader, LLSD(m_AcceptType));
|
||||
m_Header.insert(m_AgentHeader, LLSD(user_agent));
|
||||
m_Header.addHeader(m_AcceptHeader, m_AcceptType);
|
||||
m_Header.addHeader(m_AgentHeader, user_agent);
|
||||
}
|
||||
|
||||
LLHTTPClient::get(url, result, m_Header, m_GoogleTimeout);
|
||||
LLHTTPClient::get4(url, result, m_Header, m_GoogleTimeout);
|
||||
}
|
||||
|
||||
//static
|
||||
|
||||
@@ -109,7 +109,7 @@ private:
|
||||
static void stringReplaceAll(std::string& context, const std::string& from, const std::string& to);
|
||||
static BOOL parseGoogleTranslate(const std::string result, std::string &translation, std::string &detectedLanguage);
|
||||
|
||||
static LLSD m_Header;
|
||||
static AIHTTPHeaders m_Header;
|
||||
static const char* m_GoogleURL;
|
||||
static const char* m_GoogleLangSpec;
|
||||
static const char* m_AcceptHeader;
|
||||
|
||||
@@ -82,8 +82,7 @@ void LLViewerDisplayName::set(const std::string& display_name, const set_name_sl
|
||||
|
||||
// People API can return localized error messages. Indicate our
|
||||
// language preference via header.
|
||||
LLSD headers;
|
||||
headers["Accept-Language"] = LLUI::getLanguage();
|
||||
AIHTTPHeaders headers("Accept-Language", LLUI::getLanguage());
|
||||
|
||||
// People API requires both the old and new value to change a variable.
|
||||
// Our display name will be in cache before the viewer's UI is available
|
||||
@@ -110,7 +109,7 @@ void LLViewerDisplayName::set(const std::string& display_name, const set_name_sl
|
||||
// communicates with the back-end.
|
||||
LLSD body;
|
||||
body["display_name"] = change_array;
|
||||
LLHTTPClient::post(cap_url, body, new LLSetDisplayNameResponder, headers);
|
||||
LLHTTPClient::post4(cap_url, body, new LLSetDisplayNameResponder, headers);
|
||||
}
|
||||
|
||||
class LLSetDisplayNameReply : public LLHTTPNode
|
||||
|
||||
@@ -256,7 +256,7 @@ void LLViewerInventoryItem::fetchFromServer(void) const
|
||||
body["items"][0]["owner_id"] = mPermissions.getOwner();
|
||||
body["items"][0]["item_id"] = mUUID;
|
||||
|
||||
LLHTTPClient::post(url, body, new LLInventoryModel::fetchInventoryResponder(body));
|
||||
LLHTTPClient::post4(url, body, new LLInventoryModel::fetchInventoryResponder(body));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -645,17 +645,17 @@ void LLViewerMedia::setOpenIDCookie()
|
||||
getCookieStore()->setCookiesFromHost(sOpenIDCookie, authority.substr(host_start, host_end - host_start));
|
||||
|
||||
// Do a web profile get so we can store the cookie
|
||||
LLSD headers = LLSD::emptyMap();
|
||||
headers["Accept"] = "*/*";
|
||||
headers["Cookie"] = sOpenIDCookie;
|
||||
headers["User-Agent"] = getCurrentUserAgent();
|
||||
AIHTTPHeaders headers;
|
||||
headers.addHeader("Accept", "*/*");
|
||||
headers.addHeader("Cookie", sOpenIDCookie);
|
||||
headers.addHeader("User-Agent", getCurrentUserAgent());
|
||||
|
||||
std::string profile_url = getProfileURL("");
|
||||
LLURL raw_profile_url( profile_url.c_str() );
|
||||
|
||||
LL_DEBUGS("MediaAuth") << "Requesting " << profile_url << llendl;
|
||||
LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << llendl;
|
||||
LLHTTPClient::get(profile_url,
|
||||
LLHTTPClient::get4(profile_url,
|
||||
new LLViewerMediaWebProfileResponder(raw_profile_url.getAuthority()),
|
||||
headers);
|
||||
}
|
||||
@@ -676,18 +676,18 @@ void LLViewerMedia::openIDSetup(const std::string &openid_url, const std::string
|
||||
// We shouldn't ever do this twice, but just in case this code gets repurposed later, clear existing cookies.
|
||||
sOpenIDCookie.clear();
|
||||
|
||||
LLSD headers = LLSD::emptyMap();
|
||||
AIHTTPHeaders headers;
|
||||
// Keep LLHTTPClient from adding an "Accept: application/llsd+xml" header
|
||||
headers["Accept"] = "*/*";
|
||||
headers.addHeader("Accept", "*/*");
|
||||
// and use the expected content-type for a post, instead of the LLHTTPClient::postRaw() default of "application/octet-stream"
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
||||
headers.addHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
// postRaw() takes ownership of the buffer and releases it later, so we need to allocate a new buffer here.
|
||||
size_t size = openid_token.size();
|
||||
U8 *data = new U8[size];
|
||||
char* data = new char[size];
|
||||
memcpy(data, openid_token.data(), size);
|
||||
|
||||
LLHTTPClient::postRaw(
|
||||
LLHTTPClient::postRaw4(
|
||||
openid_url,
|
||||
data,
|
||||
size,
|
||||
@@ -1278,7 +1278,7 @@ void LLViewerMediaImpl::navigateTo(const std::string& url, const std::string& mi
|
||||
{
|
||||
if(mime_type.empty())
|
||||
{
|
||||
LLHTTPClient::getHeaderOnly( url, new LLMimeDiscoveryResponder(this));
|
||||
LLHTTPClient::getHeaderOnly4( url, new LLMimeDiscoveryResponder(this));
|
||||
}
|
||||
else if(initializeMedia(mime_type) && (plugin = getMediaPlugin()))
|
||||
{
|
||||
|
||||
@@ -1201,7 +1201,7 @@ void upload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_ty
|
||||
body["everyone_mask"] = LLSD::Integer(everyone_perms);
|
||||
body["expected_upload_cost"] = LLSD::Integer(expected_upload_cost);
|
||||
|
||||
LLHTTPClient::post(url, body,
|
||||
LLHTTPClient::post4(url, body,
|
||||
new LLNewAgentInventoryResponder(body, uuid, asset_type));
|
||||
}
|
||||
else
|
||||
@@ -1370,7 +1370,7 @@ void NewResourceItemCallback::fire(const LLUUID& new_item_id)
|
||||
}
|
||||
|
||||
if(agent_url.empty()) return;
|
||||
LLHTTPClient::post(agent_url, body,
|
||||
LLHTTPClient::post4(agent_url, body,
|
||||
new LLUpdateAgentInventoryResponder(body, vfile_id, new_item->getType()));
|
||||
}
|
||||
// </edit>
|
||||
|
||||
@@ -3604,7 +3604,7 @@ void process_chat_from_simulator(LLMessageSystem *msg, void **user_data)
|
||||
std::string authUrl = mesg.substr(8);
|
||||
authUrl += (authUrl.find('?') != std::string::npos)? "&auth=": "?auth=";
|
||||
authUrl += gAuthString;
|
||||
HippoRestRequest::get(authUrl, new AuthHandler());
|
||||
HippoRestRequest::get5(authUrl, new AuthHandler());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1213,7 +1213,7 @@ void myupload_new_resource(const LLTransactionID &tid, LLAssetType::EType asset_
|
||||
LLSDSerialize::toXML(body, llsdxml);
|
||||
LL_DEBUGS("ObjectBackup") << "posting body to capability: " << llsdxml.str() << LL_ENDL;
|
||||
//LLHTTPClient::post(url, body, new LLNewAgentInventoryResponder(body, uuid, asset_type));
|
||||
LLHTTPClient::post(url, body, new importResponder(body, uuid, asset_type));
|
||||
LLHTTPClient::post4(url, body, new importResponder(body, uuid, asset_type));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1109,7 +1109,7 @@ void LLViewerObjectList::fetchObjectCosts()
|
||||
LLSD post_data = LLSD::emptyMap();
|
||||
|
||||
post_data["object_ids"] = id_list;
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
post_data,
|
||||
new LLObjectCostResponder(id_list));
|
||||
@@ -1165,7 +1165,7 @@ void LLViewerObjectList::fetchPhysicsFlags()
|
||||
LLSD post_data = LLSD::emptyMap();
|
||||
|
||||
post_data["object_ids"] = id_list;
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
post_data,
|
||||
new LLPhysicsFlagsResponder(id_list));
|
||||
|
||||
@@ -467,7 +467,7 @@ void LLViewerParcelMedia::sendMediaNavigateMessage(const std::string& url)
|
||||
body["agent-id"] = gAgent.getID();
|
||||
body["local-id"] = LLViewerParcelMgr::getInstance()->getAgentParcel()->getLocalID();
|
||||
body["url"] = url;
|
||||
LLHTTPClient::post(region_url, body, new LLHTTPClient::ResponderIgnore);
|
||||
LLHTTPClient::post4(region_url, body, new LLHTTPClient::ResponderIgnore);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1310,7 +1310,7 @@ void LLViewerParcelMgr::sendParcelPropertiesUpdate(LLParcel* parcel, bool use_ag
|
||||
parcel->packMessage(body);
|
||||
llinfos << "Sending parcel properties update via capability to: "
|
||||
<< url << llendl;
|
||||
LLHTTPClient::post(url, body, new LLHTTPClient::ResponderIgnore);
|
||||
LLHTTPClient::post4(url, body, new LLHTTPClient::ResponderIgnore);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1661,9 +1661,9 @@ void LLViewerRegion::setSeedCapability(const std::string& url)
|
||||
llinfos << "posting to seed " << url << llendl;
|
||||
|
||||
S32 id = ++mImpl->mHttpResponderID;
|
||||
LLHTTPClient::post(url, capabilityNames,
|
||||
LLHTTPClient::post4(url, capabilityNames,
|
||||
BaseCapabilitiesComplete::build(getHandle(), id),
|
||||
LLSD(), CAP_REQUEST_TIMEOUT);
|
||||
CAP_REQUEST_TIMEOUT);
|
||||
}
|
||||
|
||||
S32 LLViewerRegion::getNumSeedCapRetries()
|
||||
@@ -1697,9 +1697,9 @@ void LLViewerRegion::failedSeedCapability()
|
||||
<< mImpl->mSeedCapAttempts << ")" << llendl;
|
||||
|
||||
S32 id = ++mImpl->mHttpResponderID;
|
||||
LLHTTPClient::post(url, capabilityNames,
|
||||
LLHTTPClient::post4(url, capabilityNames,
|
||||
BaseCapabilitiesComplete::build(getHandle(), id),
|
||||
LLSD(), CAP_REQUEST_TIMEOUT);
|
||||
CAP_REQUEST_TIMEOUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1743,7 +1743,7 @@ private:
|
||||
{
|
||||
mAttempt++;
|
||||
LL_WARNS2("AppInit", "SimulatorFeatures") << "Re-trying '" << mRetryURL << "'. Retry #" << mAttempt << LL_ENDL;
|
||||
LLHTTPClient::get(mRetryURL, new SimulatorFeaturesReceived(*this), LLSD(), CAP_REQUEST_TIMEOUT);
|
||||
LLHTTPClient::get4(mRetryURL, new SimulatorFeaturesReceived(*this), CAP_REQUEST_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1769,7 +1769,7 @@ void LLViewerRegion::setCapability(const std::string& name, const std::string& u
|
||||
else if (name == "SimulatorFeatures")
|
||||
{
|
||||
// kick off a request for simulator features
|
||||
LLHTTPClient::get(url, new SimulatorFeaturesReceived(url, getHandle()), LLSD(), CAP_REQUEST_TIMEOUT);
|
||||
LLHTTPClient::get4(url, new SimulatorFeaturesReceived(url, getHandle()), CAP_REQUEST_TIMEOUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -874,6 +874,6 @@ void send_stats()
|
||||
body["MinimalSkin"] = false;
|
||||
|
||||
LLViewerStats::getInstance()->addToMessage(body);
|
||||
LLHTTPClient::post(url, body, new ViewerStatsResponder());
|
||||
LLHTTPClient::post4(url, body, new ViewerStatsResponder);
|
||||
}
|
||||
|
||||
|
||||
@@ -1364,7 +1364,7 @@ void LLVoiceClient::requestVoiceAccountProvision(S32 retries)
|
||||
|
||||
if ( url == "" ) return;
|
||||
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
LLSD(),
|
||||
new LLViewerVoiceAccountProvisionResponder(retries));
|
||||
@@ -5061,7 +5061,7 @@ void LLVoiceClient::parcelChanged()
|
||||
|
||||
std::string url = gAgent.getRegion()->getCapability("ParcelVoiceInfoRequest");
|
||||
LLSD data;
|
||||
LLHTTPClient::post(
|
||||
LLHTTPClient::post4(
|
||||
url,
|
||||
data,
|
||||
new LLVoiceClientCapResponder);
|
||||
|
||||
@@ -284,7 +284,7 @@ bool LLWaterParamManager::savePresetToNotecard(const std::string & name)
|
||||
file.write((U8*)buffer.c_str(), size);
|
||||
LLSD body;
|
||||
body["item_id"] = item->getUUID();
|
||||
LLHTTPClient::post(agent_url, body, new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
|
||||
LLHTTPClient::post4(agent_url, body, new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -88,7 +88,7 @@ bool LLEnvironmentRequest::doRequest()
|
||||
}
|
||||
|
||||
LL_INFOS("WindlightCaps") << "Requesting region windlight settings via " << url << LL_ENDL;
|
||||
LLHTTPClient::get(url, new LLEnvironmentRequestResponder());
|
||||
LLHTTPClient::get4(url, new LLEnvironmentRequestResponder());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ bool LLEnvironmentApply::initiateRequest(const LLSD& content)
|
||||
|
||||
LL_INFOS("WindlightCaps") << "Sending windlight settings to " << url << LL_ENDL;
|
||||
LL_DEBUGS("WindlightCaps") << "content: " << content << LL_ENDL;
|
||||
LLHTTPClient::post(url, content, new LLEnvironmentApplyResponder());
|
||||
LLHTTPClient::post4(url, content, new LLEnvironmentApplyResponder());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -943,7 +943,7 @@ bool LLWLParamManager::savePresetToNotecard(const std::string & name)
|
||||
file.write((U8*)buffer.c_str(), size);
|
||||
LLSD body;
|
||||
body["item_id"] = item->getUUID();
|
||||
LLHTTPClient::post(agent_url, body, new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
|
||||
LLHTTPClient::post4(agent_url, body, new LLUpdateAgentInventoryResponder(body, asset_id, LLAssetType::AT_NOTECARD));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -441,7 +441,7 @@ void LLWorldMap::sendMapLayerRequest()
|
||||
if (!url.empty())
|
||||
{
|
||||
llinfos << "LLWorldMap::sendMapLayerRequest via capability" << llendl;
|
||||
LLHTTPClient::post(url, body, new LLMapLayerResponder());
|
||||
LLHTTPClient::post4(url, body, new LLMapLayerResponder);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user