From 96e343b49b0b5a0951ffab0beb2e1d09c37bbdc5 Mon Sep 17 00:00:00 2001
From: Rider Linden
Date: Tue, 1 Sep 2015 16:13:52 -0700
Subject: MAINT-5575: Convert the Experience cache into a coro based singleton.
--HG--
branch : MAINT-5575
---
indra/newview/llappviewer.cpp | 57 ++++++++++---------------------------------
1 file changed, 13 insertions(+), 44 deletions(-)
(limited to 'indra/newview/llappviewer.cpp')
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 9b9b591cd1..e13a9d96c7 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -228,7 +228,7 @@
#include "llmachineid.h"
#include "llmainlooprepeater.h"
-
+#include "llcoproceduremanager.h"
#include "llviewereventrecorder.h"
@@ -755,8 +755,11 @@ void fast_exit(int rc)
{
_exit(rc);
}
+
+
}
+
bool LLAppViewer::init()
{
setupErrorHandling(mSecondInstance);
@@ -1216,6 +1219,12 @@ bool LLAppViewer::init()
LLAgentLanguage::init();
+ /// Tell the Coprocedure manager how to discover and store the pool sizes
+ // what I wanted
+ LLCoprocedureManager::getInstance()->setPropertyMethods(
+ boost::bind(&LLControlGroup::getU32, boost::ref(gSavedSettings), _1),
+ boost::bind(&LLControlGroup::declareU32, boost::ref(gSavedSettings), _1, _2, _3, LLControlVariable::PERSIST_ALWAYS));
+
return true;
}
@@ -4700,31 +4709,6 @@ void LLAppViewer::saveNameCache()
}
-void LLAppViewer::saveExperienceCache()
-{
- std::string filename =
- gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "experience_cache.xml");
- LL_INFOS("ExperienceCache") << "Saving " << filename << LL_ENDL;
- llofstream cache_stream(filename.c_str());
- if(cache_stream.is_open())
- {
- LLExperienceCache::exportFile(cache_stream);
- }
-}
-
-void LLAppViewer::loadExperienceCache()
-{
- std::string filename =
- gDirUtilp->getExpandedFilename(LL_PATH_CACHE, "experience_cache.xml");
- LL_INFOS("ExperienceCache") << "Loading " << filename << LL_ENDL;
- llifstream cache_stream(filename.c_str());
- if(cache_stream.is_open())
- {
- LLExperienceCache::importFile(cache_stream);
- }
-}
-
-
/*! @brief This class is an LLFrameTimer that can be created with
an elapsed time that starts counting up from the given value
rather than 0.0.
@@ -4920,7 +4904,6 @@ void LLAppViewer::idle()
// floating throughout the various object lists.
//
idleNameCache();
- idleExperienceCache();
idleNetwork();
@@ -5350,22 +5333,6 @@ void LLAppViewer::idleNameCache()
LLAvatarNameCache::idle();
}
-void LLAppViewer::idleExperienceCache()
-{
- LLViewerRegion* region = gAgent.getRegion();
- if (!region) return;
-
- std::string lookup_url=region->getCapability("GetExperienceInfo");
- if(!lookup_url.empty() && *lookup_url.rbegin() != '/')
- {
- lookup_url += '/';
- }
-
- LLExperienceCache::setLookupURL(lookup_url);
-
- LLExperienceCache::idle();
-}
-
//
// Handle messages, and all message related stuff
//
@@ -5528,7 +5495,9 @@ void LLAppViewer::disconnectViewer()
}
saveNameCache();
- saveExperienceCache();
+ LLExperienceCache *expCache = LLExperienceCache::getIfExists();
+ if (expCache)
+ expCache->cleanup();
// close inventory interface, close all windows
LLFloaterInventory::cleanup();
--
cgit v1.3
From 97236a42ca08979897d5c7b0826312345754cd67 Mon Sep 17 00:00:00 2001
From: Rider Linden
Date: Mon, 14 Sep 2015 11:15:23 -0700
Subject: MAINT-5507: Remove HTTPClient and related cruft.
---
indra/llmessage/CMakeLists.txt | 3 -
indra/llmessage/llcorehttputil.cpp | 4 +
indra/llmessage/llcorehttputil.h | 1 +
indra/llmessage/llexperiencecache.cpp | 1 -
indra/llmessage/llhttpclient.cpp | 677 ---------------------------
indra/llmessage/llhttpclient.h | 201 --------
indra/llmessage/llhttpclientinterface.h | 45 --
indra/llmessage/message.cpp | 1 -
indra/newview/CMakeLists.txt | 7 -
indra/newview/llaisapi.cpp | 2 +-
indra/newview/llaisapi.h | 1 -
indra/newview/llappviewer.cpp | 3 -
indra/newview/lleventpoll.h | 1 -
indra/newview/llfloaterexperienceprofile.cpp | 1 -
indra/newview/llfloaterexperiences.cpp | 1 -
indra/newview/llgroupmgr.cpp | 1 -
indra/newview/llmarketplacefunctions.cpp | 1 -
indra/newview/llmeshrepository.h | 1 +
indra/newview/llpanelexperiencepicker.cpp | 1 -
indra/newview/llpanelgroupexperiences.cpp | 1 -
indra/newview/llsecapi.cpp | 41 --
indra/newview/llsecapi.h | 3 -
indra/newview/llsidepanelinventory.cpp | 1 -
indra/newview/llstartup.cpp | 1 -
indra/newview/lltranslate.cpp | 22 -
indra/newview/lltranslate.h | 2 -
indra/newview/lluploadfloaterobservers.h | 1 -
indra/newview/llviewermenufile.cpp | 1 -
indra/newview/llviewerregion.cpp | 1 -
indra/newview/tests/lltranslate_test.cpp | 340 --------------
30 files changed, 7 insertions(+), 1360 deletions(-)
delete mode 100755 indra/llmessage/llhttpclient.cpp
delete mode 100755 indra/llmessage/llhttpclient.h
delete mode 100755 indra/llmessage/llhttpclientinterface.h
delete mode 100755 indra/newview/tests/lltranslate_test.cpp
(limited to 'indra/newview/llappviewer.cpp')
diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt
index 41b618f8c3..aa00faf3f7 100755
--- a/indra/llmessage/CMakeLists.txt
+++ b/indra/llmessage/CMakeLists.txt
@@ -48,7 +48,6 @@ set(llmessage_SOURCE_FILES
llexperiencecache.cpp
llfiltersd2xmlrpc.cpp
llhost.cpp
- llhttpclient.cpp
llhttpconstants.cpp
llhttpnode.cpp
llhttpsdhandler.cpp
@@ -140,8 +139,6 @@ set(llmessage_HEADER_FILES
llfiltersd2xmlrpc.h
llfollowcamparams.h
llhost.h
- llhttpclient.h
- llhttpclientinterface.h
llhttpconstants.h
llhttpnode.h
llhttpnodeadapter.h
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp
index 4c2e2c5ee7..106df15bf1 100644
--- a/indra/llmessage/llcorehttputil.cpp
+++ b/indra/llmessage/llcorehttputil.cpp
@@ -46,6 +46,10 @@ using namespace LLCore;
namespace LLCoreHttpUtil
{
+
+const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f;
+
+
void logMessageSuccess(std::string logAuth, std::string url, std::string message)
{
LL_INFOS() << logAuth << " Success '" << message << "' for " << url << LL_ENDL;
diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h
index 6599a4f01a..94800b1a5b 100644
--- a/indra/llmessage/llcorehttputil.h
+++ b/indra/llmessage/llcorehttputil.h
@@ -57,6 +57,7 @@
///
namespace LLCoreHttpUtil
{
+ extern const F32 HTTP_REQUEST_EXPIRY_SECS;
/// Attempt to convert a response object's contents to LLSD.
/// It is expected that the response body will be of non-zero
diff --git a/indra/llmessage/llexperiencecache.cpp b/indra/llmessage/llexperiencecache.cpp
index 0fd6836948..ff5f7e793d 100644
--- a/indra/llmessage/llexperiencecache.cpp
+++ b/indra/llmessage/llexperiencecache.cpp
@@ -26,7 +26,6 @@
#include "llexperiencecache.h"
#include "llavatarname.h"
-#include "llhttpclient.h"
#include "llsdserialize.h"
#include "llcoros.h"
#include "lleventcoro.h"
diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp
deleted file mode 100755
index b149d24c4b..0000000000
--- a/indra/llmessage/llhttpclient.cpp
+++ /dev/null
@@ -1,677 +0,0 @@
-/**
- * @file llhttpclient.cpp
- * @brief Implementation of classes for making HTTP requests.
- *
- * $LicenseInfo:firstyear=2006&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-#include
-#include "llhttpclient.h"
-
-#include "llassetstorage.h"
-#include "lliopipe.h"
-#include "llurlrequest.h"
-#include "llbufferstream.h"
-#include "llsdserialize.h"
-#include "llvfile.h"
-#include "llvfs.h"
-#include "lluri.h"
-
-#include "message.h"
-#include "httpcommon.h"
-#include "httprequest.h"
-#include "httpoptions.h"
-
-#include
-
-
-const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f;
-LLURLRequest::SSLCertVerifyCallback LLHTTPClient::mCertVerifyCallback = NULL;
-
-////////////////////////////////////////////////////////////////////////////
-
-// Responder class moved to LLCurl
-
-namespace
-{
- class LLHTTPClientURLAdaptor : public LLURLRequestComplete
- {
- public:
- LLHTTPClientURLAdaptor(LLCurl::ResponderPtr responder)
- : LLURLRequestComplete(), mResponder(responder), mStatus(HTTP_INTERNAL_ERROR),
- mReason("LLURLRequest complete w/no status")
- {
- }
-
- ~LLHTTPClientURLAdaptor()
- {
- }
-
- virtual void httpStatus(S32 status, const std::string& reason)
- {
- LLURLRequestComplete::httpStatus(status,reason);
-
- mStatus = status;
- mReason = reason;
- }
-
- virtual void complete(const LLChannelDescriptors& channels,
- const buffer_ptr_t& buffer)
- {
- // *TODO: Re-interpret mRequestStatus codes?
- // Would like to detect curl errors, such as
- // connection errors, write erros, etc.
- if (mResponder.get())
- {
- mResponder->setResult(mStatus, mReason);
- mResponder->completedRaw(channels, buffer);
- }
- }
- virtual void header(const std::string& header, const std::string& value)
- {
- if (mResponder.get())
- {
- mResponder->setResponseHeader(header, value);
- }
- }
-
- private:
- LLCurl::ResponderPtr mResponder;
- S32 mStatus;
- std::string mReason;
- };
-
- class Injector : public LLIOPipe
- {
- public:
- virtual const std::string& contentType() = 0;
- };
-
- class LLSDInjector : public Injector
- {
- public:
- LLSDInjector(const LLSD& sd) : mSD(sd) {}
- virtual ~LLSDInjector() {}
-
- const std::string& contentType() { return HTTP_CONTENT_LLSD_XML; }
-
- 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;
- }
-
- const LLSD mSD;
- };
-
- class RawInjector : public Injector
- {
- public:
- RawInjector(const U8* data, S32 size) : mData(data), mSize(size) {}
- virtual ~RawInjector() {delete [] mData;}
-
- const std::string& contentType() { return HTTP_CONTENT_OCTET_STREAM; }
-
- 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;
- }
-
- const U8* mData;
- S32 mSize;
- };
-
- class FileInjector : public Injector
- {
- public:
- FileInjector(const std::string& filename) : mFilename(filename) {}
- virtual ~FileInjector() {}
-
- const std::string& contentType() { return HTTP_CONTENT_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.c_str(), std::iostream::binary | std::iostream::out);
- if(fstream.is_open())
- {
- fstream.seekg(0, std::ios::end);
- U32 fileSize = (U32)fstream.tellg();
- fstream.seekg(0, std::ios::beg);
- std::vector 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 std::string& contentType() { return HTTP_CONTENT_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();
- U8* fileBuffer;
- fileBuffer = new U8 [fileSize];
- vfile.read(fileBuffer, fileSize);
- ostream.write((char*)fileBuffer, fileSize);
- delete [] fileBuffer;
- eos = true;
- return STATUS_DONE;
- }
-
- const LLUUID mUUID;
- LLAssetType::EType mAssetType;
- };
-
-
- LLPumpIO* theClientPump = NULL;
-}
-
-void LLHTTPClient::setCertVerifyCallback(LLURLRequest::SSLCertVerifyCallback callback)
-{
- LLHTTPClient::mCertVerifyCallback = callback;
-}
-
-static void request(
- const std::string& url,
- EHTTPMethod method,
- Injector* body_injector,
- LLCurl::ResponderPtr responder,
- const F32 timeout = HTTP_REQUEST_EXPIRY_SECS,
- const LLSD& headers = LLSD(),
- bool follow_redirects = true
- )
-{
- if (!LLHTTPClient::hasPump())
- {
- if (responder)
- {
- responder->completeResult(HTTP_INTERNAL_ERROR, "No pump");
- }
- delete body_injector;
- return;
- }
- LLPumpIO::chain_t chain;
-
- LLURLRequest* req = new LLURLRequest(method, url, follow_redirects);
- if(!req->isValid())//failed
- {
- if (responder)
- {
- responder->completeResult(HTTP_INTERNAL_CURL_ERROR, "Internal Error - curl failure");
- }
- delete req;
- delete body_injector;
- return;
- }
-
- req->setSSLVerifyCallback(LLHTTPClient::getCertVerifyCallback(), (void *)req);
-
- LL_DEBUGS("LLHTTPClient") << httpMethodAsVerb(method) << " " << url << " " << headers << LL_ENDL;
-
- // Insert custom headers if the caller sent any
- if (headers.isMap())
- {
- if (headers.has(HTTP_OUT_HEADER_COOKIE))
- {
- req->allowCookies();
- }
-
- LLSD::map_const_iterator iter = headers.beginMap();
- LLSD::map_const_iterator 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 (read: llurlrequest.cpp)
- if ((iter->first == HTTP_OUT_HEADER_PRAGMA) && (iter->second.asString().empty()))
- {
- req->useProxy(false);
- }
- LL_DEBUGS("LLHTTPClient") << "header = " << iter->first
- << ": " << iter->second.asString() << LL_ENDL;
- req->addHeader(iter->first, iter->second.asString());
- }
- }
-
- // 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( method != HTTP_PUT && method != HTTP_POST )
- {
- if(!headers.has(HTTP_OUT_HEADER_ACCEPT))
- {
- req->addHeader(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML);
- }
- }
-
- if (responder)
- {
- responder->setURL(url);
- responder->setHTTPMethod(method);
- }
-
- req->setCallback(new LLHTTPClientURLAdaptor(responder));
-
- if (method == HTTP_POST && gMessageSystem)
- {
- req->addHeader("X-SecondLife-UDP-Listen-Port", llformat("%d",
- gMessageSystem->mPort));
- }
-
- if (method == HTTP_PUT || method == HTTP_POST || method == HTTP_PATCH)
- {
- if(!headers.has(HTTP_OUT_HEADER_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.
- req->addHeader(HTTP_OUT_HEADER_CONTENT_TYPE, body_injector->contentType());
- }
- chain.push_back(LLIOPipe::ptr_t(body_injector));
- }
-
- chain.push_back(LLIOPipe::ptr_t(req));
-
- theClientPump->addChain(chain, timeout);
-}
-
-
-void LLHTTPClient::getByteRange(
- const std::string& url,
- S32 offset,
- S32 bytes,
- ResponderPtr responder,
- const LLSD& hdrs,
- const F32 timeout,
- bool follow_redirects /* = true */)
-{
- LLSD headers = hdrs;
- if(offset > 0 || bytes > 0)
- {
- std::string range = llformat("bytes=%d-%d", offset, offset+bytes-1);
- headers[HTTP_OUT_HEADER_RANGE] = range;
- }
- request(url,HTTP_GET, NULL, responder, timeout, headers, follow_redirects);
-}
-
-void LLHTTPClient::head(
- const std::string& url,
- ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout,
- bool follow_redirects /* = true */)
-{
- request(url, HTTP_HEAD, NULL, responder, timeout, headers, follow_redirects);
-}
-
-void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout,
- bool follow_redirects /* = true */)
-{
- request(url, HTTP_GET, NULL, responder, timeout, headers, follow_redirects);
-}
-void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const LLSD& headers,
- const F32 timeout, bool follow_redirects /* = true */)
-{
- request(url, HTTP_HEAD, NULL, responder, timeout, headers, follow_redirects);
-}
-void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const F32 timeout,
- bool follow_redirects /* = true */)
-{
- getHeaderOnly(url, responder, LLSD(), timeout, follow_redirects);
-}
-
-void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const LLSD& headers,
- const F32 timeout, bool follow_redirects /* = true */)
-{
- LLURI uri;
-
- uri = LLURI::buildHTTP(url, LLSD::emptyArray(), query);
- get(uri.asString(), responder, headers, timeout, follow_redirects);
-}
-
-// A simple class for managing data returned from a curl http request.
-class LLHTTPBuffer
-{
-public:
- LLHTTPBuffer() { }
-
- static size_t curl_write( void *ptr, size_t size, size_t nmemb, void *user_data)
- {
- LLHTTPBuffer* self = (LLHTTPBuffer*)user_data;
-
- size_t bytes = (size * nmemb);
- self->mBuffer.append((char*)ptr,bytes);
- return nmemb;
- }
-
- LLSD asLLSD()
- {
- LLSD content;
-
- if (mBuffer.empty()) return content;
-
- std::istringstream istr(mBuffer);
- LLSDSerialize::fromXML(content, istr);
- return content;
- }
-
- const std::string& asString()
- {
- return mBuffer;
- }
-
-private:
- std::string mBuffer;
-};
-
-// These calls are blocking! This is usually bad, unless you're a dataserver. Then it's awesome.
-
-/**
- @brief does a blocking request on the url, returning the data or bad status.
-
- @param url URI to verb on.
- @param method the verb to hit the URI with.
- @param body the body of the call (if needed - for instance not used for GET and DELETE, but is for POST and PUT)
- @param headers HTTP headers to use for the request.
- @param timeout Curl timeout to use. Defaults to 5. Rationale:
- Without this timeout, blockingGet() calls have been observed to take
- up to 90 seconds to complete. Users of blockingGet() already must
- check the HTTP return code for validity, so this will not introduce
- new errors. A 5 second timeout will succeed > 95% of the time (and
- probably > 99% of the time) based on my statistics. JC
-
- @returns an LLSD map: {status: integer, body: map}
- */
-static LLSD blocking_request(
- const std::string& url,
- EHTTPMethod method,
- const LLSD& body,
- const LLSD& headers = LLSD(),
- const F32 timeout = 5
-)
-{
- LL_DEBUGS() << "blockingRequest of " << url << LL_ENDL;
- char curl_error_buffer[CURL_ERROR_SIZE] = "\0";
- CURL* curlp = LLCurl::newEasyHandle();
- llassert_always(curlp != NULL) ;
-
- LLHTTPBuffer http_buffer;
- std::string body_str;
-
- // other request method checks root cert first, we skip?
-
- // Apply configured proxy settings
- LLProxy::getInstance()->applyProxySettings(curlp);
-
- // * Set curl handle options
- curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts
- curl_easy_setopt(curlp, CURLOPT_TIMEOUT, timeout); // seconds, see warning at top of function.
- curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, LLHTTPBuffer::curl_write);
- curl_easy_setopt(curlp, CURLOPT_WRITEDATA, &http_buffer);
- curl_easy_setopt(curlp, CURLOPT_URL, url.c_str());
- curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curl_error_buffer);
-
- // * Setup headers (don't forget to free them after the call!)
- curl_slist* headers_list = NULL;
- if (headers.isMap())
- {
- LLSD::map_const_iterator iter = headers.beginMap();
- LLSD::map_const_iterator end = headers.endMap();
- for (; iter != end; ++iter)
- {
- std::ostringstream header;
- header << iter->first << ": " << iter->second.asString() ;
- LL_DEBUGS() << "header = " << header.str() << LL_ENDL;
- headers_list = curl_slist_append(headers_list, header.str().c_str());
- }
- }
-
- // * Setup specific method / "verb" for the URI (currently only GET and POST supported + poppy)
- if (method == HTTP_GET)
- {
- curl_easy_setopt(curlp, CURLOPT_HTTPGET, 1);
- }
- else if (method == HTTP_POST)
- {
- curl_easy_setopt(curlp, CURLOPT_POST, 1);
- //serialize to ostr then copy to str - need to because ostr ptr is unstable :(
- std::ostringstream ostr;
- LLSDSerialize::toXML(body, ostr);
- body_str = ostr.str();
- curl_easy_setopt(curlp, CURLOPT_POSTFIELDS, body_str.c_str());
- //copied from PHP libs, correct?
- headers_list = curl_slist_append(headers_list,
- llformat("%s: %s", HTTP_OUT_HEADER_CONTENT_TYPE.c_str(), HTTP_CONTENT_LLSD_XML.c_str()).c_str());
-
- // copied from llurlrequest.cpp
- // it appears that apache2.2.3 or django in etch is busted. If
- // we do not clear the expect header, we get a 500. May be
- // limited to django/mod_wsgi.
- headers_list = curl_slist_append(headers_list, llformat("%s:", HTTP_OUT_HEADER_EXPECT.c_str()).c_str());
- }
-
- // * Do the action using curl, handle results
- LL_DEBUGS() << "HTTP body: " << body_str << LL_ENDL;
- headers_list = curl_slist_append(headers_list,
- llformat("%s: %s", HTTP_OUT_HEADER_ACCEPT.c_str(), HTTP_CONTENT_LLSD_XML.c_str()).c_str());
- CURLcode curl_result = curl_easy_setopt(curlp, CURLOPT_HTTPHEADER, headers_list);
- if ( curl_result != CURLE_OK )
- {
- LL_INFOS() << "Curl is hosed - can't add headers" << LL_ENDL;
- }
-
- LLSD response = LLSD::emptyMap();
- S32 curl_success = curl_easy_perform(curlp);
- S32 http_status = HTTP_INTERNAL_ERROR;
- curl_easy_getinfo(curlp, CURLINFO_RESPONSE_CODE, &http_status);
- response["status"] = http_status;
- // if we get a non-404 and it's not a 200 OR maybe it is but you have error bits,
- if ( http_status != HTTP_NOT_FOUND && (http_status != HTTP_OK || curl_success != 0) )
- {
- // We expect 404s, don't spam for them.
- LL_WARNS() << "CURL REQ URL: " << url << LL_ENDL;
- LL_WARNS() << "CURL REQ METHOD TYPE: " << method << LL_ENDL;
- LL_WARNS() << "CURL REQ HEADERS: " << headers.asString() << LL_ENDL;
- LL_WARNS() << "CURL REQ BODY: " << body_str << LL_ENDL;
- LL_WARNS() << "CURL HTTP_STATUS: " << http_status << LL_ENDL;
- LL_WARNS() << "CURL ERROR: " << curl_error_buffer << LL_ENDL;
- LL_WARNS() << "CURL ERROR BODY: " << http_buffer.asString() << LL_ENDL;
- response["body"] = http_buffer.asString();
- }
- else
- {
- response["body"] = http_buffer.asLLSD();
- LL_DEBUGS() << "CURL response: " << http_buffer.asString() << LL_ENDL;
- }
-
- if(headers_list)
- { // free the header list
- curl_slist_free_all(headers_list);
- }
-
- // * Cleanup
- LLCurl::deleteEasyHandle(curlp);
- return response;
-}
-
-LLSD LLHTTPClient::blockingGet(const std::string& url)
-{
- return blocking_request(url, HTTP_GET, LLSD());
-}
-
-LLSD LLHTTPClient::blockingPost(const std::string& url, const LLSD& body)
-{
- return blocking_request(url, HTTP_POST, body);
-}
-
-void LLHTTPClient::put(
- const std::string& url,
- const LLSD& body,
- ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout)
-{
- request(url, HTTP_PUT, new LLSDInjector(body), responder, timeout, headers);
-}
-
-void LLHTTPClient::patch(
- const std::string& url,
- const LLSD& body,
- ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout)
-{
- request(url, HTTP_PATCH, new LLSDInjector(body), responder, timeout, headers);
-}
-
-void LLHTTPClient::putRaw(
- const std::string& url,
- const U8* data,
- S32 size,
- ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout)
-{
- request(url, HTTP_PUT, new RawInjector(data, size), responder, timeout, headers);
-}
-
-void LLHTTPClient::post(
- const std::string& url,
- const LLSD& body,
- ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout)
-{
- request(url, HTTP_POST, new LLSDInjector(body), responder, timeout, headers);
-}
-
-void LLHTTPClient::postRaw(
- const std::string& url,
- const U8* data,
- S32 size,
- ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout)
-{
- request(url, HTTP_POST, new RawInjector(data, size), responder, timeout, headers);
-}
-
-void LLHTTPClient::postFile(
- const std::string& url,
- const std::string& filename,
- ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout)
-{
- request(url, HTTP_POST, new FileInjector(filename), responder, timeout, headers);
-}
-
-void LLHTTPClient::postFile(
- const std::string& url,
- const LLUUID& uuid,
- LLAssetType::EType asset_type,
- ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout)
-{
- request(url, HTTP_POST, new VFileInjector(uuid, asset_type), responder, timeout, headers);
-}
-
-// static
-void LLHTTPClient::del(
- const std::string& url,
- ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout)
-{
- request(url, HTTP_DELETE, NULL, responder, timeout, headers);
-}
-
-// static
-void LLHTTPClient::move(
- const std::string& url,
- const std::string& destination,
- ResponderPtr responder,
- const LLSD& hdrs,
- const F32 timeout)
-{
- LLSD headers = hdrs;
- headers[HTTP_OUT_HEADER_DESTINATION] = destination;
- request(url, HTTP_MOVE, NULL, responder, timeout, headers);
-}
-
-// static
-void LLHTTPClient::copy(
- const std::string& url,
- const std::string& destination,
- ResponderPtr responder,
- const LLSD& hdrs,
- const F32 timeout)
-{
- LLSD headers = hdrs;
- headers[HTTP_OUT_HEADER_DESTINATION] = destination;
- request(url, HTTP_COPY, NULL, responder, timeout, headers);
-}
-
-
-void LLHTTPClient::setPump(LLPumpIO& pump)
-{
- theClientPump = &pump;
-}
-
-bool LLHTTPClient::hasPump()
-{
- return theClientPump != NULL;
-}
diff --git a/indra/llmessage/llhttpclient.h b/indra/llmessage/llhttpclient.h
deleted file mode 100755
index fd48b4a743..0000000000
--- a/indra/llmessage/llhttpclient.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/**
- * @file llhttpclient.h
- * @brief Declaration of classes for making HTTP client requests.
- *
- * $LicenseInfo:firstyear=2006&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLHTTPCLIENT_H
-#define LL_LLHTTPCLIENT_H
-
-/**
- * These classes represent the HTTP client framework.
- */
-
-#include
-
-#include
-#include
-#include "llurlrequest.h"
-#include "llassettype.h"
-#include "llcurl.h"
-#include "lliopipe.h"
-
-extern const F32 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;
-
-
- /** @name non-blocking API */
- //@{
- static void head(
- const std::string& url,
- ResponderPtr,
- const LLSD& headers = LLSD(),
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS,
- bool follow_redirects = true);
- static void getByteRange(const std::string& url, S32 offset, S32 bytes, ResponderPtr,
- const LLSD& headers=LLSD(), const F32 timeout=HTTP_REQUEST_EXPIRY_SECS,
- bool follow_redirects = true);
- static void get(const std::string& url, ResponderPtr, const LLSD& headers = LLSD(),
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, bool follow_redirects = true);
- static void get(const std::string& url, const LLSD& query, ResponderPtr, const LLSD& headers = LLSD(),
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, bool follow_redirects = true);
-
- static void put(
- const std::string& url,
- const LLSD& body,
- ResponderPtr,
- const LLSD& headers = LLSD(),
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
- static void putRaw(
- const std::string& url,
- const U8* data,
- S32 size,
- ResponderPtr responder,
- const LLSD& headers = LLSD(),
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
-
-
- static void patch(
- 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,
- bool follow_redirects = true);
- static void getHeaderOnly(const std::string& url, ResponderPtr, const LLSD& headers,
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS, bool follow_redirects = true);
-
- 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 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++
-
- /**
- * @brief Send a MOVE webdav method
- *
- * @param url The complete serialized (and escaped) url to get.
- * @param destination The complete serialized destination url.
- * @param responder The responder that will handle the result.
- * @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);
-
- /**
- * @brief Send a COPY webdav method
- *
- * @param url The complete serialized (and escaped) url to get.
- * @param destination The complete serialized destination url.
- * @param responder The responder that will handle the result.
- * @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 copy(
- const std::string& url,
- const std::string& destination,
- ResponderPtr responder,
- const LLSD& headers = LLSD(),
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
-
- //@}
-
- /**
- * @brief Blocking HTTP get that returns an LLSD map of status and body.
- *
- * @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);
-
- /**
- * @brief Blocking HTTP POST that returns an LLSD map of status and body.
- *
- * @param url the complete serialized (and escaped) url to get
- * @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();
-
- static void setCertVerifyCallback(LLURLRequest::SSLCertVerifyCallback callback);
- static LLURLRequest::SSLCertVerifyCallback getCertVerifyCallback() { return mCertVerifyCallback; }
-
-protected:
- static LLURLRequest::SSLCertVerifyCallback mCertVerifyCallback;
-};
-
-#endif // LL_LLHTTPCLIENT_H
diff --git a/indra/llmessage/llhttpclientinterface.h b/indra/llmessage/llhttpclientinterface.h
deleted file mode 100755
index 9c1c8e7c11..0000000000
--- a/indra/llmessage/llhttpclientinterface.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * @file llhttpclientinterface.h
- * @brief
- *
- * $LicenseInfo:firstyear=2008&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLHTTPCLIENTINTERFACE_H
-#define LL_LLHTTPCLIENTINTERFACE_H
-
-#include "linden_common.h"
-#include "llcurl.h"
-
-#include
-
-// class LLHTTPClientInterface
-// {
-// public:
-// virtual ~LLHTTPClientInterface() {}
-// virtual void get(const std::string& url, LLCurl::ResponderPtr responder) = 0;
-// virtual void get(const std::string& url, LLCurl::ResponderPtr responder, const LLSD& headers) = 0;
-// virtual void put(const std::string& url, const LLSD& body, LLCurl::ResponderPtr responder) = 0;
-// };
-
-#endif // LL_LLHTTPCLIENTINTERFACE_H
-
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp
index 10dbbef046..4f9aa5d2de 100755
--- a/indra/llmessage/message.cpp
+++ b/indra/llmessage/message.cpp
@@ -50,7 +50,6 @@
#include "lldir.h"
#include "llerror.h"
#include "llfasttimer.h"
-#include "llhttpclient.h"
#include "llhttpnodeadapter.h"
#include "llmd5.h"
#include "llmessagebuilder.h"
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 7eb4174b7f..af51c6dc36 100755
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -2224,7 +2224,6 @@ if (LL_TESTS)
# llmediadataclient.cpp
lllogininstance.cpp
# llremoteparcelrequest.cpp
-# lltranslate.cpp
llviewerhelputil.cpp
llversioninfo.cpp
llworldmap.cpp
@@ -2245,12 +2244,6 @@ if (LL_TESTS)
${CURL_LIBRARIES}
)
-# set_source_files_properties(
-# lltranslate.cpp
-# PROPERTIES
-# LL_TEST_ADDITIONAL_LIBRARIES "${test_libs}"
-# )
-
set_source_files_properties(
llmediadataclient.cpp
PROPERTIES
diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp
index da2f69126a..2d877f6a47 100755
--- a/indra/newview/llaisapi.cpp
+++ b/indra/newview/llaisapi.cpp
@@ -380,7 +380,7 @@ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t ht
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest());
LLCore::HttpHeaders::ptr_t httpHeaders;
- httpOptions->setTimeout(HTTP_REQUEST_EXPIRY_SECS);
+ httpOptions->setTimeout(LLCoreHttpUtil::HTTP_REQUEST_EXPIRY_SECS);
LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
diff --git a/indra/newview/llaisapi.h b/indra/newview/llaisapi.h
index 2de8003c2f..48c081991a 100755
--- a/indra/newview/llaisapi.h
+++ b/indra/newview/llaisapi.h
@@ -32,7 +32,6 @@
#include
#include
#include "llcurl.h"
-#include "llhttpclient.h"
#include "llhttpretrypolicy.h"
#include "llviewerinventory.h"
#include "llcorehttputil.h"
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index e13a9d96c7..16dac4a9e5 100755
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1160,8 +1160,6 @@ bool LLAppViewer::init()
{
LLNotificationsUtil::add("CorruptedProtectedDataStore");
}
- LLHTTPClient::setCertVerifyCallback(secapiSSLCertVerifyCallback);
-
gGLActive = FALSE;
@@ -1315,7 +1313,6 @@ bool LLAppViewer::mainLoop()
// Create IO Pump to use for HTTP Requests.
gServicePump = new LLPumpIO(gAPRPoolp);
- LLHTTPClient::setPump(*gServicePump);
LLCurl::setCAFile(gDirUtilp->getCAFile());
// Note: this is where gLocalSpeakerMgr and gActiveSpeakerMgr used to be instantiated.
diff --git a/indra/newview/lleventpoll.h b/indra/newview/lleventpoll.h
index e32b4ed322..e2afd9226b 100755
--- a/indra/newview/lleventpoll.h
+++ b/indra/newview/lleventpoll.h
@@ -27,7 +27,6 @@
#ifndef LL_LLEVENTPOLL_H
#define LL_LLEVENTPOLL_H
-#include "llhttpclient.h"
#include "boost/move/unique_ptr.hpp"
namespace boost
diff --git a/indra/newview/llfloaterexperienceprofile.cpp b/indra/newview/llfloaterexperienceprofile.cpp
index dd1c6dce0a..d44eb4310d 100644
--- a/indra/newview/llfloaterexperienceprofile.cpp
+++ b/indra/newview/llfloaterexperienceprofile.cpp
@@ -36,7 +36,6 @@
#include "llexpandabletextbox.h"
#include "llexperiencecache.h"
#include "llfloaterreg.h"
-#include "llhttpclient.h"
#include "lllayoutstack.h"
#include "lllineeditor.h"
#include "llnotificationsutil.h"
diff --git a/indra/newview/llfloaterexperiences.cpp b/indra/newview/llfloaterexperiences.cpp
index 14fbdb3a8f..bdab9ed868 100644
--- a/indra/newview/llfloaterexperiences.cpp
+++ b/indra/newview/llfloaterexperiences.cpp
@@ -32,7 +32,6 @@
#include "llevents.h"
#include "llexperiencecache.h"
#include "llfloaterregioninfo.h"
-#include "llhttpclient.h"
#include "llnotificationsutil.h"
#include "llpanelexperiencelog.h"
#include "llpanelexperiencepicker.h"
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp
index eda9e51d23..b218f4f756 100755
--- a/indra/newview/llgroupmgr.cpp
+++ b/indra/newview/llgroupmgr.cpp
@@ -41,7 +41,6 @@
#include "llui.h"
#include "message.h"
#include "roles_constants.h"
-#include "llhttpclient.h"
#include "lltransactiontypes.h"
#include "llstatusbar.h"
#include "lleconomy.h"
diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp
index cff8446545..b0cd1dd23e 100755
--- a/indra/newview/llmarketplacefunctions.cpp
+++ b/indra/newview/llmarketplacefunctions.cpp
@@ -30,7 +30,6 @@
#include "llagent.h"
#include "llbufferstream.h"
-#include "llhttpclient.h"
#include "llinventoryfunctions.h"
#include "llinventoryobserver.h"
#include "llnotificationsutil.h"
diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h
index 55157cc040..ed20641312 100755
--- a/indra/newview/llmeshrepository.h
+++ b/indra/newview/llmeshrepository.h
@@ -38,6 +38,7 @@
#include "httpoptions.h"
#include "httpheaders.h"
#include "httphandler.h"
+#include "llthread.h"
#define LLCONVEXDECOMPINTER_STATIC 1
diff --git a/indra/newview/llpanelexperiencepicker.cpp b/indra/newview/llpanelexperiencepicker.cpp
index d71ced443b..dcc5f4f234 100644
--- a/indra/newview/llpanelexperiencepicker.cpp
+++ b/indra/newview/llpanelexperiencepicker.cpp
@@ -42,7 +42,6 @@
#include "llviewercontrol.h"
#include "llfloater.h"
#include "lltrans.h"
-#include "llhttpclient.h" // *TODO: Rider, remove when converting
#define BTN_FIND "find"
#define BTN_OK "ok_btn"
diff --git a/indra/newview/llpanelgroupexperiences.cpp b/indra/newview/llpanelgroupexperiences.cpp
index 9b4c67a120..a88a55ab22 100644
--- a/indra/newview/llpanelgroupexperiences.cpp
+++ b/indra/newview/llpanelgroupexperiences.cpp
@@ -31,7 +31,6 @@
#include "lluictrlfactory.h"
#include "roles_constants.h"
-#include "llhttpclient.h"
#include "llagent.h"
#include "llviewerregion.h"
#include "llflatlistview.h"
diff --git a/indra/newview/llsecapi.cpp b/indra/newview/llsecapi.cpp
index 43bb7b1596..4f9f83b6f2 100755
--- a/indra/newview/llsecapi.cpp
+++ b/indra/newview/llsecapi.cpp
@@ -32,7 +32,6 @@
#include
#include
#include ",
- "Привет", "", "");
- }
-
- template<> template<>
- void translate_test_object_t::test<14>()
- {
- test_translation(mBing, 200,
- "Привет",
- "Привет", "", "");
- }
-
- template<> template<>
- void translate_test_object_t::test<15>()
- {
- test_translation(mBing, 200,
- "Привет",
- "Привет", "", "");
- }
-
- template<> template<>
- void translate_test_object_t::test<16>()
- {
- test_translation(mBing, 400,
- "Message: some error
",
- "", "", "some error");
- }
-
- template<> template<>
- void translate_test_object_t::test<17>()
- {
- test_translation(mBing, 400,
- "Message: some error",
- "", "", "some error");
- }
-
- template<> template<>
- void translate_test_object_t::test<18>()
- {
- test_translation(mBing, 400,
- "some error",
- "", "", "some error");
- }
-
- template<> template<>
- void translate_test_object_t::test<19>()
- {
- test_translation(mBing, 400,
- "some error",
- "", "", "some error");
- }
-
- template<> template<>
- void translate_test_object_t::test<20>()
- {
- std::string url;
- mBing.getTranslateURL(url, "en", "es", "hi");
- ensure_equals("bing URL", url,
- "http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=dummy&text=hi&to=es&from=en");
- }
-
- template<> template<>
- void translate_test_object_t::test<21>()
- {
- std::string url;
- mBing.getTranslateURL(url, "", "es", "hi");
- ensure_equals("bing URL", url,
- "http://api.microsofttranslator.com/v2/Http.svc/Translate?appId=dummy&text=hi&to=es");
- }
-
- template<> template<>
- void translate_test_object_t::test<22>()
- {
- std::string url;
- mGoogle.getTranslateURL(url, "en", "es", "hi");
- ensure_equals("google URL", url,
- "https://www.googleapis.com/language/translate/v2?key=dummy&q=hi&target=es&source=en");
- }
-
- template<> template<>
- void translate_test_object_t::test<23>()
- {
- std::string url;
- mGoogle.getTranslateURL(url, "", "es", "hi");
- ensure_equals("google URL", url,
- "https://www.googleapis.com/language/translate/v2?key=dummy&q=hi&target=es");
- }
-}
-
-//== Misc stubs ===============================================================
-LLControlGroup gSavedSettings("test");
-
-std::string LLUI::getLanguage() { return "en"; }
-std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil::format_map_t& args) { return "dummy"; }
-
-LLControlGroup::LLControlGroup(const std::string& name) : LLInstanceTracker(name) {}
-std::string LLControlGroup::getString(const std::string& name) { return "dummy"; }
-LLControlGroup::~LLControlGroup() {}
-
-LLCurl::Responder::Responder() {}
-void LLCurl::Responder::httpFailure() { }
-void LLCurl::Responder::httpSuccess() { }
-void LLCurl::Responder::httpCompleted() { }
-void LLCurl::Responder::completedRaw(LLChannelDescriptors const &,boost::shared_ptr const &) { }
-LLCurl::Responder::~Responder() {}
-
-void LLHTTPClient::get(const std::string&, const LLSD&, ResponderPtr, const LLSD&, const F32, bool) {}
-void LLHTTPClient::get(const std::string&, LLPointer, const LLSD&, const F32, bool) {}
-
-LLBufferStream::LLBufferStream(const LLChannelDescriptors& channels, LLBufferArray* buffer)
-: std::iostream(&mStreamBuf), mStreamBuf(channels, buffer) {}
-LLBufferStream::~LLBufferStream() {}
-
-LLBufferStreamBuf::LLBufferStreamBuf(const LLChannelDescriptors&, LLBufferArray*) {}
-#if( LL_WINDOWS || __GNUC__ > 2)
-LLBufferStreamBuf::pos_type LLBufferStreamBuf::seekoff(
- off_type off,
- std::ios::seekdir way,
- std::ios::openmode which)
-#else
-streampos LLBufferStreamBuf::seekoff(
- streamoff off,
- std::ios::seekdir way,
- std::ios::openmode which)
-#endif
-{ return 0; }
-int LLBufferStreamBuf::sync() {return 0;}
-int LLBufferStreamBuf::underflow() {return 0;}
-int LLBufferStreamBuf::overflow(int) {return 0;}
-LLBufferStreamBuf::~LLBufferStreamBuf() {}
-
-S32 LLVersionInfo::getBuild() { return 0; }
-const std::string& LLVersionInfo::getChannel() {static std::string dummy; return dummy;}
-S32 LLVersionInfo::getMajor() { return 0; }
-S32 LLVersionInfo::getMinor() { return 0; }
-S32 LLVersionInfo::getPatch() { return 0; }
--
cgit v1.3
From 196caf21a828f114daf95fe02d81d8690cb1e8a8 Mon Sep 17 00:00:00 2001
From: Rider Linden
Date: Mon, 14 Sep 2015 16:10:20 -0700
Subject: MAINT-5507: Removal of sdrpc client/server MAINT-5507: removal of
LLCurl::Easy, LLCurl::Multi LLCurl::Responder
---
indra/llmessage/llcurl.cpp | 1707 +------------------------------------
indra/llmessage/llcurl.h | 341 +-------
indra/llmessage/llproxy.cpp | 10 -
indra/llmessage/llproxy.h | 14 +-
indra/llmessage/llsdrpcclient.cpp | 249 ------
indra/llmessage/llsdrpcclient.h | 226 -----
indra/llmessage/llsdrpcserver.cpp | 341 --------
indra/llmessage/llsdrpcserver.h | 361 --------
indra/llmessage/llurlrequest.cpp | 785 -----------------
indra/llmessage/llurlrequest.h | 357 --------
indra/newview/llappviewer.cpp | 12 -
indra/test/io.cpp | 422 ---------
12 files changed, 22 insertions(+), 4803 deletions(-)
delete mode 100755 indra/llmessage/llsdrpcclient.cpp
delete mode 100755 indra/llmessage/llsdrpcclient.h
delete mode 100755 indra/llmessage/llsdrpcserver.cpp
delete mode 100755 indra/llmessage/llsdrpcserver.h
delete mode 100755 indra/llmessage/llurlrequest.cpp
delete mode 100755 indra/llmessage/llurlrequest.h
(limited to 'indra/newview/llappviewer.cpp')
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index 630e5ebe71..61b7a52c76 100755
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -89,7 +89,7 @@ S32 gCurlMultiCount = 0;
std::vector LLCurl::sSSLMutex;
std::string LLCurl::sCAPath;
std::string LLCurl::sCAFile;
-LLCurlThread* LLCurl::sCurlThread = NULL ;
+//LLCurlThread* LLCurl::sCurlThread = NULL ;
LLMutex* LLCurl::sHandleMutexp = NULL ;
S32 LLCurl::sTotalHandles = 0 ;
bool LLCurl::sNotQuitting = true;
@@ -135,1042 +135,6 @@ std::string LLCurl::getVersionString()
return std::string(curl_version());
}
-//////////////////////////////////////////////////////////////////////////////
-
-LLCurl::Responder::Responder()
- : mHTTPMethod(HTTP_INVALID), mStatus(HTTP_INTERNAL_ERROR)
-{
-}
-
-LLCurl::Responder::~Responder()
-{
- LL_CHECK_MEMORY
-}
-
-// virtual
-void LLCurl::Responder::httpFailure()
-{
- LL_WARNS("curl") << dumpResponse() << LL_ENDL;
-}
-
-std::string LLCurl::Responder::dumpResponse() const
-{
- std::ostringstream s;
- s << "[" << httpMethodAsVerb(mHTTPMethod) << ":" << mURL << "] "
- << "[status:" << mStatus << "] "
- << "[reason:" << mReason << "] ";
-
- if (mResponseHeaders.has(HTTP_IN_HEADER_CONTENT_TYPE))
- {
- s << "[content-type:" << mResponseHeaders[HTTP_IN_HEADER_CONTENT_TYPE] << "] ";
- }
-
- s << "[content:" << mContent << "]";
-
- return s.str();
-}
-
-// virtual
-void LLCurl::Responder::httpSuccess()
-{
-}
-
-void LLCurl::Responder::setURL(const std::string& url)
-{
- mURL = url;
-}
-
-void LLCurl::Responder::successResult(const LLSD& content)
-{
- setResult(HTTP_OK, "", content);
- httpSuccess();
-}
-
-void LLCurl::Responder::failureResult(S32 status, const std::string& reason, const LLSD& content /* = LLSD() */)
-{
- setResult(status, reason, content);
- httpFailure();
-}
-
-void LLCurl::Responder::completeResult(S32 status, const std::string& reason, const LLSD& content /* = LLSD() */)
-{
- setResult(status, reason, content);
- httpCompleted();
-}
-
-void LLCurl::Responder::setResult(S32 status, const std::string& reason, const LLSD& content /* = LLSD() */)
-{
- mStatus = status;
- mReason = reason;
- mContent = content;
-}
-
-void LLCurl::Responder::setHTTPMethod(EHTTPMethod method)
-{
- mHTTPMethod = method;
-}
-
-void LLCurl::Responder::setResponseHeader(const std::string& header, const std::string& value)
-{
- mResponseHeaders[header] = value;
-}
-
-const std::string& LLCurl::Responder::getResponseHeader(const std::string& header) const
-{
- if (mResponseHeaders.has(header))
- {
- return mResponseHeaders[header].asStringRef();
- }
- static const std::string empty;
- return empty;
-}
-
-bool LLCurl::Responder::hasResponseHeader(const std::string& header) const
-{
- if (mResponseHeaders.has(header)) return true;
- return false;
-}
-
-// virtual
-void LLCurl::Responder::completedRaw(
- const LLChannelDescriptors& channels,
- const LLIOPipe::buffer_ptr_t& buffer)
-{
- LLBufferStream istr(channels, buffer.get());
- const bool emit_parse_errors = false;
-
- std::string debug_body("(empty)");
- bool parsed=true;
- if (EOF == istr.peek())
- {
- parsed=false;
- }
- // Try to parse body as llsd, no matter what 'content-type' says.
- else if (LLSDParser::PARSE_FAILURE == LLSDSerialize::fromXML(mContent, istr, emit_parse_errors))
- {
- parsed=false;
- char body[1025];
- body[1024] = '\0';
- istr.seekg(0, std::ios::beg);
- istr.get(body,1024);
- if (strlen(body) > 0)
- {
- mContent = body;
- debug_body = body;
- }
- }
-
- // Only emit a warning if we failed to parse when 'content-type' == 'application/llsd+xml'
- if (!parsed && (HTTP_CONTENT_LLSD_XML == getResponseHeader(HTTP_IN_HEADER_CONTENT_TYPE)))
- {
- LL_WARNS() << "Failed to deserialize . " << mURL << " [status:" << mStatus << "] "
- << "(" << mReason << ") body: " << debug_body << LL_ENDL;
- }
-
- httpCompleted();
-}
-
-// virtual
-void LLCurl::Responder::httpCompleted()
-{
- if (isGoodStatus())
- {
- httpSuccess();
- }
- else
- {
- httpFailure();
- }
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
-std::set LLCurl::Easy::sFreeHandles;
-std::set LLCurl::Easy::sActiveHandles;
-LLMutex* LLCurl::Easy::sHandleMutexp = NULL ;
-
-//static
-CURL* LLCurl::Easy::allocEasyHandle()
-{
- llassert(LLCurl::getCurlThread()) ;
-
- CURL* ret = NULL;
-
- LLMutexLock lock(sHandleMutexp) ;
-
- if (sFreeHandles.empty())
- {
- ret = LLCurl::newEasyHandle();
- }
- else
- {
- ret = *(sFreeHandles.begin());
- sFreeHandles.erase(ret);
- curl_easy_reset(ret);
- }
-
- if (ret)
- {
- sActiveHandles.insert(ret);
- }
-
- return ret;
-}
-
-//static
-void LLCurl::Easy::releaseEasyHandle(CURL* handle)
-{
- static const S32 MAX_NUM_FREE_HANDLES = 32 ;
-
- if (!handle)
- {
- return ; //handle allocation failed.
- //LL_ERRS() << "handle cannot be NULL!" << LL_ENDL;
- }
-
- LLMutexLock lock(sHandleMutexp) ;
- if (sActiveHandles.find(handle) != sActiveHandles.end())
- {
- LL_CHECK_MEMORY
- sActiveHandles.erase(handle);
- LL_CHECK_MEMORY
- if(sFreeHandles.size() < MAX_NUM_FREE_HANDLES)
- {
- sFreeHandles.insert(handle);
- LL_CHECK_MEMORY
- }
- else
- {
- LLCurl::deleteEasyHandle(handle) ;
- LL_CHECK_MEMORY
- }
- }
- else
- {
- LL_ERRS() << "Invalid handle." << LL_ENDL;
- }
-}
-
-//static
-void LLCurl::Easy::deleteAllActiveHandles()
-{
- LLMutexLock lock(sHandleMutexp) ;
- LL_CHECK_MEMORY
- for (std::set::iterator activeHandle = sActiveHandles.begin(); activeHandle != sActiveHandles.end(); ++activeHandle)
- {
- CURL* curlHandle = *activeHandle;
- LLCurl::deleteEasyHandle(curlHandle);
- LL_CHECK_MEMORY
- }
-
- sFreeHandles.clear();
-}
-
-//static
-void LLCurl::Easy::deleteAllFreeHandles()
-{
- LLMutexLock lock(sHandleMutexp) ;
- LL_CHECK_MEMORY
- for (std::set::iterator freeHandle = sFreeHandles.begin(); freeHandle != sFreeHandles.end(); ++freeHandle)
- {
- CURL* curlHandle = *freeHandle;
- LLCurl::deleteEasyHandle(curlHandle);
- LL_CHECK_MEMORY
- }
-
- sFreeHandles.clear();
-}
-
-LLCurl::Easy::Easy()
- : mHeaders(NULL),
- mCurlEasyHandle(NULL)
-{
- mErrorBuffer[0] = 0;
-}
-
-LLCurl::Easy* LLCurl::Easy::getEasy()
-{
- Easy* easy = new Easy();
- easy->mCurlEasyHandle = allocEasyHandle();
-
- if (!easy->mCurlEasyHandle)
- {
- // this can happen if we have too many open files (fails in c-ares/ares_init.c)
- LL_WARNS("curl") << "allocEasyHandle() returned NULL! Easy handles: "
- << gCurlEasyCount << " Multi handles: " << gCurlMultiCount << LL_ENDL;
- delete easy;
- return NULL;
- }
-
- // Enable a brief cache period for now. This was zero for the longest time
- // which caused some routers grief and generated unneeded traffic. For the
- // threaded resolver, we're using system resolution libraries and non-zero values
- // are preferred. The c-ares resolver is another matter and it might not
- // track server changes as well.
- CURLcode result = curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_DNS_CACHE_TIMEOUT, 15);
- check_curl_code(result);
- result = curl_easy_setopt(easy->mCurlEasyHandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
- check_curl_code(result);
-
- ++gCurlEasyCount;
- return easy;
-}
-
-LLCurl::Easy::~Easy()
-{
- releaseEasyHandle(mCurlEasyHandle);
- --gCurlEasyCount;
- curl_slist_free_all(mHeaders);
- LL_CHECK_MEMORY
- for_each(mStrings.begin(), mStrings.end(), DeletePointerArray());
- LL_CHECK_MEMORY
- if (mResponder && LLCurl::sNotQuitting) //aborted
- {
- // HTTP_REQUEST_TIME_OUT, timeout, abort
- // *TODO: This looks like improper use of the 408 status code.
- // See: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.9
- // This status code should be returned by the *server* when:
- // "The client did not produce a request within the time that the server was prepared to wait."
- mResponder->setResult(HTTP_REQUEST_TIME_OUT, "Request timeout, aborted.");
- mResponder->completedRaw(mChannels, mOutput);
- LL_CHECK_MEMORY
- }
- mResponder = NULL;
-}
-
-void LLCurl::Easy::resetState()
-{
- curl_easy_reset(mCurlEasyHandle);
-
- if (mHeaders)
- {
- curl_slist_free_all(mHeaders);
- mHeaders = NULL;
- }
-
- mRequest.str("");
- mRequest.clear();
-
- mOutput.reset();
-
- mInput.str("");
- mInput.clear();
-
- mErrorBuffer[0] = 0;
-
- mHeaderOutput.str("");
- mHeaderOutput.clear();
-}
-
-void LLCurl::Easy::setErrorBuffer()
-{
- setopt(CURLOPT_ERRORBUFFER, &mErrorBuffer);
-}
-
-const char* LLCurl::Easy::getErrorBuffer()
-{
- return mErrorBuffer;
-}
-
-void LLCurl::Easy::setCA()
-{
- if (!sCAPath.empty())
- {
- setoptString(CURLOPT_CAPATH, sCAPath);
- }
- if (!sCAFile.empty())
- {
- setoptString(CURLOPT_CAINFO, sCAFile);
- }
-}
-
-void LLCurl::Easy::setHeaders()
-{
- setopt(CURLOPT_HTTPHEADER, mHeaders);
-}
-
-void LLCurl::Easy::getTransferInfo(LLCurl::TransferInfo* info)
-{
- check_curl_code(curl_easy_getinfo(mCurlEasyHandle, CURLINFO_SIZE_DOWNLOAD, &info->mSizeDownload));
- check_curl_code(curl_easy_getinfo(mCurlEasyHandle, CURLINFO_TOTAL_TIME, &info->mTotalTime));
- check_curl_code(curl_easy_getinfo(mCurlEasyHandle, CURLINFO_SPEED_DOWNLOAD, &info->mSpeedDownload));
-}
-
-S32 LLCurl::Easy::report(CURLcode code)
-{
- S32 responseCode = 0;
- std::string responseReason;
-
- if (code == CURLE_OK)
- {
- check_curl_code(curl_easy_getinfo(mCurlEasyHandle, CURLINFO_RESPONSE_CODE, &responseCode));
- //*TODO: get reason from first line of mHeaderOutput
- }
- else
- {
- responseCode = HTTP_INTERNAL_ERROR;
- responseReason = strerror(code) + " : " + mErrorBuffer;
- setopt(CURLOPT_FRESH_CONNECT, TRUE);
- }
-
- if (mResponder)
- {
- mResponder->setResult(responseCode, responseReason);
- mResponder->completedRaw(mChannels, mOutput);
- mResponder = NULL;
- }
-
- resetState();
- return responseCode;
-}
-
-// Note: these all assume the caller tracks the value (i.e. keeps it persistant)
-void LLCurl::Easy::setopt(CURLoption option, S32 value)
-{
- CURLcode result = curl_easy_setopt(mCurlEasyHandle, option, value);
- check_curl_code(result);
-}
-
-void LLCurl::Easy::setopt(CURLoption option, void* value)
-{
- CURLcode result = curl_easy_setopt(mCurlEasyHandle, option, value);
- check_curl_code(result);
-}
-
-void LLCurl::Easy::setopt(CURLoption option, char* value)
-{
- CURLcode result = curl_easy_setopt(mCurlEasyHandle, option, value);
- check_curl_code(result);
-}
-
-// Note: this copies the string so that the caller does not have to keep it around
-void LLCurl::Easy::setoptString(CURLoption option, const std::string& value)
-{
- char* tstring = new char[value.length()+1];
- strcpy(tstring, value.c_str());
- mStrings.push_back(tstring);
- CURLcode result = curl_easy_setopt(mCurlEasyHandle, option, tstring);
- check_curl_code(result);
-}
-
-void LLCurl::Easy::slist_append(const std::string& header, const std::string& value)
-{
- std::string pair(header);
- if (value.empty())
- {
- pair += ":";
- }
- else
- {
- pair += ": ";
- pair += value;
- }
- slist_append(pair.c_str());
-}
-
-void LLCurl::Easy::slist_append(const char* str)
-{
- if (str)
- {
- mHeaders = curl_slist_append(mHeaders, str);
- if (!mHeaders)
- {
- LL_WARNS() << "curl_slist_append() call returned NULL appending " << str << LL_ENDL;
- }
- }
-}
-
-size_t curlReadCallback(char* data, size_t size, size_t nmemb, void* user_data)
-{
- LLCurl::Easy* easy = (LLCurl::Easy*)user_data;
-
- S32 n = size * nmemb;
- S32 startpos = (S32)easy->getInput().tellg();
- easy->getInput().seekg(0, std::ios::end);
- S32 endpos = (S32)easy->getInput().tellg();
- easy->getInput().seekg(startpos, std::ios::beg);
- S32 maxn = endpos - startpos;
- n = llmin(n, maxn);
- easy->getInput().read((char*)data, n);
-
- return n;
-}
-
-size_t curlWriteCallback(char* data, size_t size, size_t nmemb, void* user_data)
-{
- LLCurl::Easy* easy = (LLCurl::Easy*)user_data;
-
- S32 n = size * nmemb;
- easy->getOutput()->append(easy->getChannels().in(), (const U8*)data, n);
-
- return n;
-}
-
-size_t curlHeaderCallback(void* data, size_t size, size_t nmemb, void* user_data)
-{
- LLCurl::Easy* easy = (LLCurl::Easy*)user_data;
-
- size_t n = size * nmemb;
- easy->getHeaderOutput().write((const char*)data, n);
-
- return n;
-}
-
-void LLCurl::Easy::prepRequest(const std::string& url,
- const std::vector& headers,
- ResponderPtr responder, S32 time_out, bool post)
-{
- resetState();
-
- if (post) setoptString(CURLOPT_ENCODING, "");
-
- //setopt(CURLOPT_VERBOSE, 1); // useful for debugging
- setopt(CURLOPT_NOSIGNAL, 1);
- setopt(CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
-
- // Set the CURL options for either Socks or HTTP proxy
- LLProxy::getInstance()->applyProxySettings(this);
-
- mOutput.reset(new LLBufferArray);
- mOutput->setThreaded(true);
- setopt(CURLOPT_WRITEFUNCTION, (void*)&curlWriteCallback);
- setopt(CURLOPT_WRITEDATA, (void*)this);
-
- setopt(CURLOPT_READFUNCTION, (void*)&curlReadCallback);
- setopt(CURLOPT_READDATA, (void*)this);
-
- setopt(CURLOPT_HEADERFUNCTION, (void*)&curlHeaderCallback);
- setopt(CURLOPT_HEADERDATA, (void*)this);
-
- // Allow up to five redirects
- if (responder && responder->followRedir())
- {
- setopt(CURLOPT_FOLLOWLOCATION, 1);
- setopt(CURLOPT_MAXREDIRS, MAX_REDIRECTS);
- }
-
- setErrorBuffer();
- setCA();
-
- setopt(CURLOPT_SSL_VERIFYPEER, true);
-
- //don't verify host name so urls with scrubbed host names will work (improves DNS performance)
- setopt(CURLOPT_SSL_VERIFYHOST, 0);
- setopt(CURLOPT_TIMEOUT, llmax(time_out, CURL_REQUEST_TIMEOUT));
- setopt(CURLOPT_CONNECTTIMEOUT, CURL_CONNECT_TIMEOUT);
-
- setoptString(CURLOPT_URL, url);
-
- mResponder = responder;
-
- if (!post)
- {
- // *TODO: Should this be set to 'Keep-Alive' ?
- slist_append(HTTP_OUT_HEADER_CONNECTION, "keep-alive");
- slist_append(HTTP_OUT_HEADER_KEEP_ALIVE, "300");
- // Accept and other headers
- for (std::vector::const_iterator iter = headers.begin();
- iter != headers.end(); ++iter)
- {
- slist_append((*iter).c_str());
- }
- }
-}
-
-////////////////////////////////////////////////////////////////////////////
-#if 1
-LLCurl::Multi::Multi(F32 idle_time_out)
- : mQueued(0),
- mErrorCount(0),
- mState(STATE_READY),
- mDead(FALSE),
- mValid(TRUE),
- mMutexp(NULL),
- mDeletionMutexp(NULL),
- mEasyMutexp(NULL)
-{
- mCurlMultiHandle = LLCurl::newMultiHandle();
- if (!mCurlMultiHandle)
- {
- LL_WARNS() << "curl_multi_init() returned NULL! Easy handles: " << gCurlEasyCount << " Multi handles: " << gCurlMultiCount << LL_ENDL;
- mCurlMultiHandle = LLCurl::newMultiHandle();
- }
-
- //llassert_always(mCurlMultiHandle);
-
- if(mCurlMultiHandle)
- {
- if(LLCurl::getCurlThread()->getThreaded())
- {
- mMutexp = new LLMutex(NULL) ;
- mDeletionMutexp = new LLMutex(NULL) ;
- mEasyMutexp = new LLMutex(NULL) ;
- }
- LLCurl::getCurlThread()->addMulti(this) ;
-
- mIdleTimeOut = idle_time_out ;
- if(mIdleTimeOut < LLCurl::sCurlRequestTimeOut)
- {
- mIdleTimeOut = LLCurl::sCurlRequestTimeOut ;
- }
-
- ++gCurlMultiCount;
-}
-}
-
-LLCurl::Multi::~Multi()
-{
- cleanup(true) ;
-
- delete mDeletionMutexp ;
- mDeletionMutexp = NULL ;
-}
-
-void LLCurl::Multi::cleanup(bool deleted)
-{
- if(!mCurlMultiHandle)
- {
- return ; //nothing to clean.
- }
- llassert_always(deleted || !mValid) ;
-
- LLMutexLock lock(mDeletionMutexp);
-
-
- // Clean up active
- for(easy_active_list_t::iterator iter = mEasyActiveList.begin();
- iter != mEasyActiveList.end(); ++iter)
- {
- Easy* easy = *iter;
- LL_CHECK_MEMORY
- check_curl_multi_code(curl_multi_remove_handle(mCurlMultiHandle, easy->getCurlHandle()));
- LL_CHECK_MEMORY
- if(deleted)
- {
- easy->mResponder = NULL ; //avoid triggering mResponder.
- LL_CHECK_MEMORY
- }
- delete easy;
- LL_CHECK_MEMORY
- }
- mEasyActiveList.clear();
- mEasyActiveMap.clear();
-
- LL_CHECK_MEMORY
-
- // Clean up freed
- for_each(mEasyFreeList.begin(), mEasyFreeList.end(), DeletePointer());
- mEasyFreeList.clear();
-
- LL_CHECK_MEMORY
-
- check_curl_multi_code(LLCurl::deleteMultiHandle(mCurlMultiHandle));
- mCurlMultiHandle = NULL ;
-
- LL_CHECK_MEMORY
-
- delete mMutexp ;
- mMutexp = NULL ;
-
- LL_CHECK_MEMORY
-
- delete mEasyMutexp ;
- mEasyMutexp = NULL ;
-
- LL_CHECK_MEMORY
-
- mQueued = 0 ;
- mState = STATE_COMPLETED;
-
- --gCurlMultiCount;
-
- return ;
-}
-
-void LLCurl::Multi::lock()
-{
- if(mMutexp)
- {
- mMutexp->lock() ;
- }
-}
-
-void LLCurl::Multi::unlock()
-{
- if(mMutexp)
- {
- mMutexp->unlock() ;
- }
-}
-
-void LLCurl::Multi::markDead()
-{
- {
- LLMutexLock lock(mDeletionMutexp) ;
-
- if(mCurlMultiHandle != NULL)
- {
- mDead = TRUE ;
- LLCurl::getCurlThread()->setPriority(mHandle, LLQueuedThread::PRIORITY_URGENT) ;
-
- return;
- }
- }
-
- //not valid, delete it.
- delete this;
-}
-
-void LLCurl::Multi::setState(LLCurl::Multi::ePerformState state)
-{
- lock() ;
- mState = state ;
- unlock() ;
-
- if(mState == STATE_READY)
- {
- LLCurl::getCurlThread()->setPriority(mHandle, LLQueuedThread::PRIORITY_NORMAL) ;
- }
-}
-
-LLCurl::Multi::ePerformState LLCurl::Multi::getState()
-{
- return mState;
-}
-
-bool LLCurl::Multi::isCompleted()
-{
- return STATE_COMPLETED == getState() ;
-}
-
-bool LLCurl::Multi::waitToComplete()
-{
- if(!isValid())
- {
- return true ;
- }
-
- if(!mMutexp) //not threaded
- {
- doPerform() ;
- return true ;
- }
-
- bool completed = (STATE_COMPLETED == mState) ;
- if(!completed)
- {
- LLCurl::getCurlThread()->setPriority(mHandle, LLQueuedThread::PRIORITY_HIGH) ;
- }
-
- return completed;
-}
-
-CURLMsg* LLCurl::Multi::info_read(S32* msgs_in_queue)
-{
- LLMutexLock lock(mMutexp) ;
-
- CURLMsg* curlmsg = curl_multi_info_read(mCurlMultiHandle, msgs_in_queue);
- return curlmsg;
-}
-
-//return true if dead
-bool LLCurl::Multi::doPerform()
-{
- LLMutexLock lock(mDeletionMutexp) ;
-
- bool dead = mDead ;
-
- if(mDead)
- {
- setState(STATE_COMPLETED);
- mQueued = 0 ;
- }
- else if(getState() != STATE_COMPLETED)
- {
- setState(STATE_PERFORMING);
-
- S32 q = 0;
- for (S32 call_count = 0;
- call_count < MULTI_PERFORM_CALL_REPEAT;
- call_count++)
- {
- LLMutexLock lock(mMutexp) ;
-
- //WARNING: curl_multi_perform will block for many hundreds of milliseconds
- // NEVER call this from the main thread, and NEVER allow the main thread to
- // wait on a mutex held by this thread while curl_multi_perform is executing
- CURLMcode code = curl_multi_perform(mCurlMultiHandle, &q);
- if (CURLM_CALL_MULTI_PERFORM != code || q == 0)
- {
- check_curl_multi_code(code);
-
- break;
- }
- }
-
- mQueued = q;
- setState(STATE_COMPLETED) ;
- mIdleTimer.reset() ;
- }
- else if(!mValid && mIdleTimer.getElapsedTimeF32() > mIdleTimeOut) //idle for too long, remove it.
- {
- dead = true ;
- }
- else if(mValid && mIdleTimer.getElapsedTimeF32() > mIdleTimeOut - 1.f) //idle for too long, mark it invalid.
- {
- mValid = FALSE ;
- }
-
- return dead ;
-}
-
-S32 LLCurl::Multi::process()
-{
- if(!isValid())
- {
- return 0 ;
- }
-
- waitToComplete() ;
-
- if (getState() != STATE_COMPLETED)
- {
- return 0;
- }
-
- CURLMsg* msg;
- int msgs_in_queue;
-
- S32 processed = 0;
- while ((msg = info_read(&msgs_in_queue)))
- {
- ++processed;
- if (msg->msg == CURLMSG_DONE)
- {
- S32 response = 0;
- Easy* easy = NULL ;
-
- {
- LLMutexLock lock(mEasyMutexp) ;
- easy_active_map_t::iterator iter = mEasyActiveMap.find(msg->easy_handle);
- if (iter != mEasyActiveMap.end())
- {
- easy = iter->second;
- }
- }
-
- if(easy)
- {
- response = easy->report(msg->data.result);
- removeEasy(easy);
- }
- else
- {
- response = HTTP_INTERNAL_ERROR;
- //*TODO: change to LL_WARNS()
- LL_ERRS() << "cleaned up curl request completed!" << LL_ENDL;
- }
- if (response >= 400)
- {
- // failure of some sort, inc mErrorCount for debugging and flagging multi for destruction
- ++mErrorCount;
- }
- }
- }
-
- setState(STATE_READY);
-
- return processed;
-}
-
-LLCurl::Easy* LLCurl::Multi::allocEasy()
-{
- Easy* easy = 0;
-
- if (mEasyFreeList.empty())
- {
- easy = Easy::getEasy();
- }
- else
- {
- LLMutexLock lock(mEasyMutexp) ;
- easy = *(mEasyFreeList.begin());
- mEasyFreeList.erase(easy);
- }
- if (easy)
- {
- LLMutexLock lock(mEasyMutexp) ;
- mEasyActiveList.insert(easy);
- mEasyActiveMap[easy->getCurlHandle()] = easy;
- }
- return easy;
-}
-
-bool LLCurl::Multi::addEasy(Easy* easy)
-{
- LLMutexLock lock(mMutexp) ;
- CURLMcode mcode = curl_multi_add_handle(mCurlMultiHandle, easy->getCurlHandle());
- check_curl_multi_code(mcode);
- //if (mcode != CURLM_OK)
- //{
- // LL_WARNS() << "Curl Error: " << curl_multi_strerror(mcode) << LL_ENDL;
- // return false;
- //}
- return true;
-}
-
-void LLCurl::Multi::easyFree(Easy* easy)
-{
- if(mEasyMutexp)
- {
- mEasyMutexp->lock() ;
- }
-
- mEasyActiveList.erase(easy);
- mEasyActiveMap.erase(easy->getCurlHandle());
-
- if (mEasyFreeList.size() < EASY_HANDLE_POOL_SIZE)
- {
- mEasyFreeList.insert(easy);
-
- if(mEasyMutexp)
- {
- mEasyMutexp->unlock() ;
- }
-
- easy->resetState();
- }
- else
- {
- if(mEasyMutexp)
- {
- mEasyMutexp->unlock() ;
- }
- delete easy;
- }
-}
-
-void LLCurl::Multi::removeEasy(Easy* easy)
-{
- {
- LLMutexLock lock(mMutexp) ;
- check_curl_multi_code(curl_multi_remove_handle(mCurlMultiHandle, easy->getCurlHandle()));
- }
- easyFree(easy);
-}
-
-#endif
-
-#if 1
-//------------------------------------------------------------
-//LLCurlThread
-LLCurlThread::CurlRequest::CurlRequest(handle_t handle, LLCurl::Multi* multi, LLCurlThread* curl_thread) :
- LLQueuedThread::QueuedRequest(handle, LLQueuedThread::PRIORITY_NORMAL, FLAG_AUTO_COMPLETE),
- mMulti(multi),
- mCurlThread(curl_thread)
-{
-}
-
-LLCurlThread::CurlRequest::~CurlRequest()
-{
- if(mMulti)
- {
- mCurlThread->deleteMulti(mMulti) ;
- mMulti = NULL ;
- }
-}
-
-bool LLCurlThread::CurlRequest::processRequest()
-{
- bool completed = true ;
- if(mMulti)
- {
- completed = mCurlThread->doMultiPerform(mMulti) ;
-
- if(!completed)
- {
- setPriority(LLQueuedThread::PRIORITY_LOW) ;
- }
- }
-
- return completed ;
-}
-
-void LLCurlThread::CurlRequest::finishRequest(bool completed)
-{
- if(mMulti->isDead())
- {
- mCurlThread->deleteMulti(mMulti) ;
- }
- else
- {
- mCurlThread->cleanupMulti(mMulti) ; //being idle too long, remove the request.
- }
-
- mMulti = NULL ;
-}
-
-LLCurlThread::LLCurlThread(bool threaded) :
- LLQueuedThread("curlthread", threaded)
-{
-}
-
-//virtual
-LLCurlThread::~LLCurlThread()
-{
-}
-
-S32 LLCurlThread::update(F32 max_time_ms)
-{
- return LLQueuedThread::update(max_time_ms);
-}
-
-void LLCurlThread::addMulti(LLCurl::Multi* multi)
-{
- multi->mHandle = generateHandle() ;
-
- CurlRequest* req = new CurlRequest(multi->mHandle, multi, this) ;
-
- if (!addRequest(req))
- {
- LL_WARNS() << "curl request added when the thread is quitted" << LL_ENDL;
- }
-}
-
-void LLCurlThread::killMulti(LLCurl::Multi* multi)
-{
- if(!multi)
- {
- return ;
- }
-
-
- multi->markDead() ;
-}
-
-//private
-bool LLCurlThread::doMultiPerform(LLCurl::Multi* multi)
-{
- return multi->doPerform() ;
-}
-
-//private
-void LLCurlThread::deleteMulti(LLCurl::Multi* multi)
-{
- delete multi ;
-}
-
-//private
-void LLCurlThread::cleanupMulti(LLCurl::Multi* multi)
-{
- multi->cleanup() ;
- if(multi->isDead()) //check if marked dead during cleaning up.
- {
- deleteMulti(multi) ;
- }
-}
-#endif
-//------------------------------------------------------------
//static
std::string LLCurl::strerror(CURLcode errorcode)
@@ -1178,641 +142,6 @@ std::string LLCurl::strerror(CURLcode errorcode)
return std::string(curl_easy_strerror(errorcode));
}
-////////////////////////////////////////////////////////////////////////////
-// For generating a simple request for data
-// using one multi and one easy per request
-
-// LLCurlRequest::LLCurlRequest() :
-// mActiveMulti(NULL),
-// mActiveRequestCount(0)
-// {
-// mProcessing = FALSE;
-// }
-//
-// LLCurlRequest::~LLCurlRequest()
-// {
-// //stop all Multi handle background threads
-// for (curlmulti_set_t::iterator iter = mMultiSet.begin(); iter != mMultiSet.end(); ++iter)
-// {
-// LLCurl::getCurlThread()->killMulti(*iter) ;
-// }
-// mMultiSet.clear() ;
-// }
-//
-// void LLCurlRequest::addMulti()
-// {
-// LLCurl::Multi* multi = new LLCurl::Multi();
-// if(!multi->isValid())
-// {
-// LLCurl::getCurlThread()->killMulti(multi) ;
-// mActiveMulti = NULL ;
-// mActiveRequestCount = 0 ;
-// return;
-// }
-//
-// mMultiSet.insert(multi);
-// mActiveMulti = multi;
-// mActiveRequestCount = 0;
-// }
-//
-// LLCurl::Easy* LLCurlRequest::allocEasy()
-// {
-// if (!mActiveMulti ||
-// mActiveRequestCount >= MAX_ACTIVE_REQUEST_COUNT ||
-// mActiveMulti->mErrorCount > 0)
-// {
-// addMulti();
-// }
-// if(!mActiveMulti)
-// {
-// return NULL ;
-// }
-//
-// //llassert_always(mActiveMulti);
-// ++mActiveRequestCount;
-// LLCurl::Easy* easy = mActiveMulti->allocEasy();
-// return easy;
-// }
-//
-// bool LLCurlRequest::addEasy(LLCurl::Easy* easy)
-// {
-// llassert_always(mActiveMulti);
-//
-// if (mProcessing)
-// {
-// LL_ERRS() << "Posting to a LLCurlRequest instance from within a responder is not allowed (causes DNS timeouts)." << LL_ENDL;
-// }
-// bool res = mActiveMulti->addEasy(easy);
-// return res;
-// }
-//
-// void LLCurlRequest::get(const std::string& url, LLCurl::ResponderPtr responder)
-// {
-// getByteRange(url, headers_t(), 0, -1, responder);
-// }
-//
-// // Note: (length==0) is interpreted as "the rest of the file", i.e. the whole file if (offset==0) or
-// // the remainder of the file if not.
-// bool LLCurlRequest::getByteRange(const std::string& url,
-// const headers_t& headers,
-// S32 offset, S32 length,
-// LLCurl::ResponderPtr responder)
-// {
-// llassert(LLCurl::sNotQuitting);
-// LLCurl::Easy* easy = allocEasy();
-// if (!easy)
-// {
-// return false;
-// }
-// easy->prepRequest(url, headers, responder);
-// easy->setopt(CURLOPT_HTTPGET, 1);
-// if (length > 0)
-// {
-// std::string range = llformat("bytes=%d-%d", offset,offset+length-1);
-// easy->slist_append(HTTP_OUT_HEADER_RANGE, range);
-// }
-// else if (offset > 0)
-// {
-// std::string range = llformat("bytes=%d-", offset);
-// easy->slist_append(HTTP_OUT_HEADER_RANGE, range);
-// }
-// easy->setHeaders();
-// bool res = addEasy(easy);
-// return res;
-// }
-//
-// bool LLCurlRequest::post(const std::string& url,
-// const headers_t& headers,
-// const LLSD& data,
-// LLCurl::ResponderPtr responder, S32 time_out)
-// {
-// llassert(LLCurl::sNotQuitting);
-// LLCurl::Easy* easy = allocEasy();
-// if (!easy)
-// {
-// return false;
-// }
-// easy->prepRequest(url, headers, responder, time_out);
-//
-// LLSDSerialize::toXML(data, easy->getInput());
-// S32 bytes = easy->getInput().str().length();
-//
-// easy->setopt(CURLOPT_POST, 1);
-// easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL);
-// easy->setopt(CURLOPT_POSTFIELDSIZE, bytes);
-//
-// easy->slist_append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML);
-// easy->setHeaders();
-//
-// LL_DEBUGS() << "POSTING: " << bytes << " bytes." << LL_ENDL;
-// bool res = addEasy(easy);
-// return res;
-// }
-//
-// bool LLCurlRequest::post(const std::string& url,
-// const headers_t& headers,
-// const std::string& data,
-// LLCurl::ResponderPtr responder, S32 time_out)
-// {
-// llassert(LLCurl::sNotQuitting);
-// LLCurl::Easy* easy = allocEasy();
-// if (!easy)
-// {
-// return false;
-// }
-// easy->prepRequest(url, headers, responder, time_out);
-//
-// easy->getInput().write(data.data(), data.size());
-// S32 bytes = easy->getInput().str().length();
-//
-// easy->setopt(CURLOPT_POST, 1);
-// easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL);
-// easy->setopt(CURLOPT_POSTFIELDSIZE, bytes);
-//
-// easy->slist_append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_OCTET_STREAM);
-// easy->setHeaders();
-//
-// LL_DEBUGS() << "POSTING: " << bytes << " bytes." << LL_ENDL;
-// bool res = addEasy(easy);
-// return res;
-// }
-//
-// // Note: call once per frame
-// S32 LLCurlRequest::process()
-// {
-// S32 res = 0;
-//
-// mProcessing = TRUE;
-// for (curlmulti_set_t::iterator iter = mMultiSet.begin();
-// iter != mMultiSet.end(); )
-// {
-// curlmulti_set_t::iterator curiter = iter++;
-// LLCurl::Multi* multi = *curiter;
-//
-// if(!multi->isValid())
-// {
-// if(multi == mActiveMulti)
-// {
-// mActiveMulti = NULL ;
-// mActiveRequestCount = 0 ;
-// }
-// mMultiSet.erase(curiter) ;
-// LLCurl::getCurlThread()->killMulti(multi) ;
-// continue ;
-// }
-//
-// S32 tres = multi->process();
-// res += tres;
-// if (multi != mActiveMulti && tres == 0 && multi->mQueued == 0)
-// {
-// mMultiSet.erase(curiter);
-// LLCurl::getCurlThread()->killMulti(multi);
-// }
-// }
-// mProcessing = FALSE;
-// return res;
-// }
-//
-// S32 LLCurlRequest::getQueued()
-// {
-// S32 queued = 0;
-// for (curlmulti_set_t::iterator iter = mMultiSet.begin();
-// iter != mMultiSet.end(); )
-// {
-// curlmulti_set_t::iterator curiter = iter++;
-// LLCurl::Multi* multi = *curiter;
-//
-// if(!multi->isValid())
-// {
-// if(multi == mActiveMulti)
-// {
-// mActiveMulti = NULL ;
-// mActiveRequestCount = 0 ;
-// }
-// LLCurl::getCurlThread()->killMulti(multi);
-// mMultiSet.erase(curiter) ;
-// continue ;
-// }
-//
-// queued += multi->mQueued;
-// if (multi->getState() != LLCurl::Multi::STATE_READY)
-// {
-// ++queued;
-// }
-// }
-// return queued;
-// }
-
-// LLCurlTextureRequest::LLCurlTextureRequest(S32 concurrency) :
-// LLCurlRequest(),
-// mConcurrency(concurrency),
-// mInQueue(0),
-// mMutex(NULL),
-// mHandleCounter(1),
-// mTotalIssuedRequests(0),
-// mTotalReceivedBits(0)
-// {
-// mGlobalTimer.reset();
-// }
-//
-// LLCurlTextureRequest::~LLCurlTextureRequest()
-// {
-// mRequestMap.clear();
-//
-// for(req_queue_t::iterator iter = mCachedRequests.begin(); iter != mCachedRequests.end(); ++iter)
-// {
-// delete *iter;
-// }
-// mCachedRequests.clear();
-// }
-//
-// //return 0: success
-// // > 0: cached handle
-// U32 LLCurlTextureRequest::getByteRange(const std::string& url,
-// const headers_t& headers,
-// S32 offset, S32 length, U32 pri,
-// LLCurl::ResponderPtr responder, F32 delay_time)
-// {
-// U32 ret_val = 0;
-// bool success = false;
-//
-// if(mInQueue < mConcurrency && delay_time < 0.f)
-// {
-// success = LLCurlRequest::getByteRange(url, headers, offset, length, responder);
-// }
-//
-// LLMutexLock lock(&mMutex);
-//
-// if(success)
-// {
-// mInQueue++;
-// mTotalIssuedRequests++;
-// }
-// else
-// {
-// request_t* request = new request_t(mHandleCounter, url, headers, offset, length, pri, responder);
-// if(delay_time > 0.f)
-// {
-// request->mStartTime = mGlobalTimer.getElapsedTimeF32() + delay_time;
-// }
-//
-// mCachedRequests.insert(request);
-// mRequestMap[mHandleCounter] = request;
-// ret_val = mHandleCounter;
-// mHandleCounter++;
-//
-// if(!mHandleCounter)
-// {
-// mHandleCounter = 1;
-// }
-// }
-//
-// return ret_val;
-// }
-//
-// void LLCurlTextureRequest::completeRequest(S32 received_bytes)
-// {
-// LLMutexLock lock(&mMutex);
-//
-// llassert_always(mInQueue > 0);
-//
-// mInQueue--;
-// mTotalReceivedBits += received_bytes * 8;
-// }
-//
-// void LLCurlTextureRequest::nextRequests()
-// {
-// if(mCachedRequests.empty() || mInQueue >= mConcurrency)
-// {
-// return;
-// }
-//
-// F32 cur_time = mGlobalTimer.getElapsedTimeF32();
-//
-// req_queue_t::iterator iter;
-// {
-// LLMutexLock lock(&mMutex);
-// iter = mCachedRequests.begin();
-// }
-// while(1)
-// {
-// request_t* request = *iter;
-// if(request->mStartTime < cur_time)
-// {
-// if(!LLCurlRequest::getByteRange(request->mUrl, request->mHeaders, request->mOffset, request->mLength, request->mResponder))
-// {
-// break;
-// }
-//
-// LLMutexLock lock(&mMutex);
-// ++iter;
-// mInQueue++;
-// mTotalIssuedRequests++;
-// mCachedRequests.erase(request);
-// mRequestMap.erase(request->mHandle);
-// delete request;
-//
-// if(iter == mCachedRequests.end() || mInQueue >= mConcurrency)
-// {
-// break;
-// }
-// }
-// else
-// {
-// LLMutexLock lock(&mMutex);
-// ++iter;
-// if(iter == mCachedRequests.end() || mInQueue >= mConcurrency)
-// {
-// break;
-// }
-// }
-// }
-//
-// return;
-// }
-//
-// void LLCurlTextureRequest::updatePriority(U32 handle, U32 pri)
-// {
-// if(!handle)
-// {
-// return;
-// }
-//
-// LLMutexLock lock(&mMutex);
-//
-// std::map::iterator iter = mRequestMap.find(handle);
-// if(iter != mRequestMap.end())
-// {
-// request_t* req = iter->second;
-//
-// if(req->mPriority != pri)
-// {
-// mCachedRequests.erase(req);
-// req->mPriority = pri;
-// mCachedRequests.insert(req);
-// }
-// }
-// }
-//
-// void LLCurlTextureRequest::removeRequest(U32 handle)
-// {
-// if(!handle)
-// {
-// return;
-// }
-//
-// LLMutexLock lock(&mMutex);
-//
-// std::map::iterator iter = mRequestMap.find(handle);
-// if(iter != mRequestMap.end())
-// {
-// request_t* req = iter->second;
-// mRequestMap.erase(iter);
-// mCachedRequests.erase(req);
-// delete req;
-// }
-// }
-//
-// bool LLCurlTextureRequest::isWaiting(U32 handle)
-// {
-// if(!handle)
-// {
-// return false;
-// }
-//
-// LLMutexLock lock(&mMutex);
-// return mRequestMap.find(handle) != mRequestMap.end();
-// }
-//
-// U32 LLCurlTextureRequest::getTotalReceivedBits()
-// {
-// LLMutexLock lock(&mMutex);
-//
-// U32 bits = mTotalReceivedBits;
-// mTotalReceivedBits = 0;
-// return bits;
-// }
-//
-// U32 LLCurlTextureRequest::getTotalIssuedRequests()
-// {
-// LLMutexLock lock(&mMutex);
-// return mTotalIssuedRequests;
-// }
-//
-// S32 LLCurlTextureRequest::getNumRequests()
-// {
-// LLMutexLock lock(&mMutex);
-// return mInQueue;
-// }
-
-////////////////////////////////////////////////////////////////////////////
-// For generating one easy request
-// associated with a single multi request
-
-LLCurlEasyRequest::LLCurlEasyRequest()
- : mRequestSent(false),
- mResultReturned(false)
-{
- mMulti = new LLCurl::Multi();
-
- if(mMulti->isValid())
- {
- mEasy = mMulti->allocEasy();
- if (mEasy)
- {
- mEasy->setErrorBuffer();
- mEasy->setCA();
- // Set proxy settings if configured to do so.
- LLProxy::getInstance()->applyProxySettings(mEasy);
- }
-}
- else
- {
- LLCurl::getCurlThread()->killMulti(mMulti) ;
- mEasy = NULL ;
- mMulti = NULL ;
- }
-}
-
-LLCurlEasyRequest::~LLCurlEasyRequest()
-{
- LLCurl::getCurlThread()->killMulti(mMulti) ;
-}
-
-void LLCurlEasyRequest::setopt(CURLoption option, S32 value)
-{
- if (isValid() && mEasy)
- {
- mEasy->setopt(option, value);
- }
-}
-
-void LLCurlEasyRequest::setoptString(CURLoption option, const std::string& value)
-{
- if (isValid() && mEasy)
- {
- mEasy->setoptString(option, value);
- }
-}
-
-void LLCurlEasyRequest::setPost(char* postdata, S32 size)
-{
- if (isValid() && mEasy)
- {
- mEasy->setopt(CURLOPT_POST, 1);
- mEasy->setopt(CURLOPT_POSTFIELDS, postdata);
- mEasy->setopt(CURLOPT_POSTFIELDSIZE, size);
- }
-}
-
-void LLCurlEasyRequest::setHeaderCallback(curl_header_callback callback, void* userdata)
-{
- if (isValid() && mEasy)
- {
- mEasy->setopt(CURLOPT_HEADERFUNCTION, (void*)callback);
- mEasy->setopt(CURLOPT_HEADERDATA, userdata); // aka CURLOPT_WRITEHEADER
- }
-}
-
-void LLCurlEasyRequest::setWriteCallback(curl_write_callback callback, void* userdata)
-{
- if (isValid() && mEasy)
- {
- mEasy->setopt(CURLOPT_WRITEFUNCTION, (void*)callback);
- mEasy->setopt(CURLOPT_WRITEDATA, userdata);
- }
-}
-
-void LLCurlEasyRequest::setReadCallback(curl_read_callback callback, void* userdata)
-{
- if (isValid() && mEasy)
- {
- mEasy->setopt(CURLOPT_READFUNCTION, (void*)callback);
- mEasy->setopt(CURLOPT_READDATA, userdata);
- }
-}
-
-void LLCurlEasyRequest::setSSLCtxCallback(curl_ssl_ctx_callback callback, void* userdata)
-{
- if (isValid() && mEasy)
- {
- mEasy->setopt(CURLOPT_SSL_CTX_FUNCTION, (void*)callback);
- mEasy->setopt(CURLOPT_SSL_CTX_DATA, userdata);
- }
-}
-
-void LLCurlEasyRequest::slist_append(const std::string& header, const std::string& value)
-{
- if (isValid() && mEasy)
- {
- mEasy->slist_append(header, value);
- }
-}
-
-void LLCurlEasyRequest::slist_append(const char* str)
-{
- if (isValid() && mEasy)
- {
- mEasy->slist_append(str);
- }
-}
-
-void LLCurlEasyRequest::sendRequest(const std::string& url)
-{
- llassert_always(!mRequestSent);
- mRequestSent = true;
- LL_DEBUGS() << url << LL_ENDL;
- if (isValid() && mEasy)
- {
- mEasy->setHeaders();
- mEasy->setoptString(CURLOPT_URL, url);
- mMulti->addEasy(mEasy);
- }
-}
-
-void LLCurlEasyRequest::requestComplete()
-{
- llassert_always(mRequestSent);
- mRequestSent = false;
- if (isValid() && mEasy)
- {
- mMulti->removeEasy(mEasy);
- }
-}
-
-// Usage: Call getRestult until it returns false (no more messages)
-bool LLCurlEasyRequest::getResult(CURLcode* result, LLCurl::TransferInfo* info)
-{
- if(!isValid())
- {
- return false ;
- }
- if (!mMulti->isCompleted())
- { //we're busy, try again later
- return false;
- }
- mMulti->setState(LLCurl::Multi::STATE_READY) ;
-
- if (!mEasy)
- {
- // Special case - we failed to initialize a curl_easy (can happen if too many open files)
- // Act as though the request failed to connect
- if (mResultReturned)
- {
- return false;
- }
- else
- {
- *result = CURLE_FAILED_INIT;
- mResultReturned = true;
- return true;
- }
- }
- // In theory, info_read might return a message with a status other than CURLMSG_DONE
- // In practice for all messages returned, msg == CURLMSG_DONE
- // Ignore other messages just in case
- while(1)
- {
- S32 q;
- CURLMsg* curlmsg = info_read(&q, info);
- if (curlmsg)
- {
- if (curlmsg->msg == CURLMSG_DONE)
- {
- *result = curlmsg->data.result;
- return true;
- }
- // else continue
- }
- else
- {
- return false;
- }
- }
-}
-
-// private
-CURLMsg* LLCurlEasyRequest::info_read(S32* q, LLCurl::TransferInfo* info)
-{
- if (mEasy)
- {
- CURLMsg* curlmsg = mMulti->info_read(q);
- if (curlmsg && curlmsg->msg == CURLMSG_DONE)
- {
- if (info)
- {
- mEasy->getTransferInfo(info);
- }
- }
- return curlmsg;
- }
- return NULL;
-}
-
-std::string LLCurlEasyRequest::getErrorString()
-{
- return isValid() && mEasy ? std::string(mEasy->getErrorBuffer()) : std::string();
-}
////////////////////////////////////////////////////////////////////////////
@@ -1859,11 +188,11 @@ void LLCurl::initClass(F32 curl_reuest_timeout, S32 max_number_handles, bool mul
CRYPTO_set_locking_callback(&LLCurl::ssl_locking_callback);
#endif
- sCurlThread = new LLCurlThread(multi_threaded) ;
+// sCurlThread = new LLCurlThread(multi_threaded) ;
if(multi_threaded)
{
sHandleMutexp = new LLMutex(NULL) ;
- Easy::sHandleMutexp = new LLMutex(NULL) ;
+// Easy::sHandleMutexp = new LLMutex(NULL) ;
}
}
@@ -1872,18 +201,18 @@ void LLCurl::cleanupClass()
sNotQuitting = false; //set quitting
//shut down curl thread
- while(1)
- {
- if(!sCurlThread->update(1)) //finish all tasks
- {
- break ;
- }
- }
+// while(1)
+// {
+// if(!sCurlThread->update(1)) //finish all tasks
+// {
+// break ;
+// }
+// }
LL_CHECK_MEMORY
- sCurlThread->shutdown() ;
+// sCurlThread->shutdown() ;
LL_CHECK_MEMORY
- delete sCurlThread ;
- sCurlThread = NULL ;
+// delete sCurlThread ;
+// sCurlThread = NULL ;
LL_CHECK_MEMORY
#if SAFE_SSL
@@ -1892,21 +221,13 @@ void LLCurl::cleanupClass()
sSSLMutex.clear();
#endif
- LL_CHECK_MEMORY
- Easy::deleteAllFreeHandles();
- LL_CHECK_MEMORY
- Easy::deleteAllActiveHandles();
- LL_CHECK_MEMORY
+ LL_CHECK_MEMORY
// Free the template easy handle
curl_easy_cleanup(sCurlTemplateStandardHandle);
sCurlTemplateStandardHandle = NULL;
LL_CHECK_MEMORY
- delete Easy::sHandleMutexp ;
- Easy::sHandleMutexp = NULL ;
-
- LL_CHECK_MEMORY
delete sHandleMutexp ;
sHandleMutexp = NULL ;
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index ca70462d0e..289e4bfd22 100755
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -48,7 +48,7 @@
#include "llsingleton.h"
class LLMutex;
-class LLCurlThread;
+//class LLCurlThread;
// For whatever reason, this is not typedef'd in curl.h
typedef size_t (*curl_header_callback)(void *ptr, size_t size, size_t nmemb, void *stream);
@@ -58,114 +58,6 @@ class LLCurl
LOG_CLASS(LLCurl);
public:
- class Easy;
- class Multi;
-
- struct TransferInfo
- {
- TransferInfo() : mSizeDownload(0.0), mTotalTime(0.0), mSpeedDownload(0.0) {}
- F64 mSizeDownload;
- F64 mTotalTime;
- F64 mSpeedDownload;
- };
-
- class Responder : public LLThreadSafeRefCount
- {
- //LOG_CLASS(Responder);
- public:
-
- Responder();
- virtual ~Responder();
-
- virtual bool followRedir()
- {
- return false;
- }
-
- /**
- * @brief return true if the status code indicates success.
- */
- bool isGoodStatus() const { return isHttpGoodStatus(mStatus); }
-
- S32 getStatus() const { return mStatus; }
- const std::string& getReason() const { return mReason; }
- const LLSD& getContent() const { return mContent; }
- bool hasResponseHeader(const std::string& header) const;
- const std::string& getResponseHeader(const std::string& header) const;
- const LLSD& getResponseHeaders() const { return mResponseHeaders; }
- const std::string& getURL() const { return mURL; }
- EHTTPMethod getHTTPMethod() const { return mHTTPMethod; }
-
- // This formats response information for use in log spam. Includes content spam.
- std::string dumpResponse() const;
-
- // Allows direct triggering of success/error with different results.
- void completeResult(S32 status, const std::string& reason, const LLSD& content = LLSD());
- void successResult(const LLSD& content);
- void failureResult(S32 status, const std::string& reason, const LLSD& content = LLSD());
-
- // The default implementation will try to parse body content as an LLSD, however
- // it should not spam about parsing failures unless the server sent a
- // Content-Type: application/llsd+xml header.
- virtual void completedRaw(
- const LLChannelDescriptors& channels,
- const LLIOPipe::buffer_ptr_t& buffer);
- /**< Override point for clients that may want to use this
- class when the response is some other format besides LLSD
- */
-
-
- // The http* methods are not public since these should be triggered internally
- // after status, reason, content, etc have been set.
- // If you need to trigger a completion method, use the *Result methods, above.
- protected:
- // These methods are the preferred way to process final results.
- // By default, when one of these is called the following information will be resolved:
- // * HTTP status code - getStatus()
- // * Reason string - getReason()
- // * Content - getContent()
- // * Response Headers - getResponseHeaders()
-
- // By default, httpSuccess is triggered whenever httpCompleted is called with a 2xx status code.
- virtual void httpSuccess();
- //< called by completed for good status codes.
-
- // By default, httpFailure is triggered whenever httpCompleted is called with a non-2xx status code.
- virtual void httpFailure();
- //< called by httpCompleted() on bad status
-
- // httpCompleted does not generally need to be overridden, unless
- // you don't care about the status code (which determine httpFailure or httpSuccess)
- // or if you want to re-interpret what a 'good' vs' bad' status code is.
- virtual void httpCompleted();
- /**< The default implementation calls
- either:
- * httpSuccess(), or
- * httpFailure()
- */
-
- public:
- void setHTTPMethod(EHTTPMethod method);
- void setURL(const std::string& url);
- void setResult(S32 status, const std::string& reason, const LLSD& content = LLSD());
- void setResponseHeader(const std::string& header, const std::string& value);
-
- private:
- // These can be accessed by the get* methods. Treated as 'read-only' during completion handlers.
- EHTTPMethod mHTTPMethod;
- std::string mURL;
- LLSD mResponseHeaders;
-
- protected:
- // These should also generally be treated as 'read-only' during completion handlers
- // and should be accessed by the get* methods. The exception to this rule would
- // be when overriding the completedRaw method in preparation for calling httpCompleted().
- S32 mStatus;
- std::string mReason;
- LLSD mContent;
- };
- typedef LLPointer ResponderPtr;
-
/**
* @ brief Set certificate authority file used to verify HTTPS certs.
@@ -214,7 +106,7 @@ public:
static void ssl_locking_callback(int mode, int type, const char *file, int line);
static unsigned long ssl_thread_id(void);
- static LLCurlThread* getCurlThread() { return sCurlThread ;}
+// static LLCurlThread* getCurlThread() { return sCurlThread ;}
static CURLM* newMultiHandle() ;
static CURLMcode deleteMultiHandle(CURLM* handle) ;
@@ -227,7 +119,8 @@ private:
static std::string sCAPath;
static std::string sCAFile;
static const unsigned int MAX_REDIRECTS;
- static LLCurlThread* sCurlThread;
+ // static LLCurlThread* sCurlThread;
+// static LLCurlThread* sCurlThread;
static LLMutex* sHandleMutexp ;
static S32 sTotalHandles ;
@@ -238,232 +131,6 @@ public:
static F32 sCurlRequestTimeOut;
};
-class LLCurl::Easy
-{
- LOG_CLASS(Easy);
-
-private:
- Easy();
-
-public:
- static Easy* getEasy();
- ~Easy();
-
- CURL* getCurlHandle() const { return mCurlEasyHandle; }
-
- void setErrorBuffer();
- void setCA();
-
- void setopt(CURLoption option, S32 value);
- // These assume the setter does not free value!
- void setopt(CURLoption option, void* value);
- void setopt(CURLoption option, char* value);
- // Copies the string so that it is guaranteed to stick around
- void setoptString(CURLoption option, const std::string& value);
-
- void slist_append(const std::string& header, const std::string& value);
- void slist_append(const char* str);
- void setHeaders();
-
- S32 report(CURLcode);
- void getTransferInfo(LLCurl::TransferInfo* info);
-
- void prepRequest(const std::string& url, const std::vector& headers, LLCurl::ResponderPtr, S32 time_out = 0, bool post = false);
-
- const char* getErrorBuffer();
-
- std::stringstream& getInput() { return mInput; }
- std::stringstream& getHeaderOutput() { return mHeaderOutput; }
- LLIOPipe::buffer_ptr_t& getOutput() { return mOutput; }
- const LLChannelDescriptors& getChannels() { return mChannels; }
-
- void resetState();
-
- static CURL* allocEasyHandle();
- static void releaseEasyHandle(CURL* handle);
-
-private:
- friend class LLCurl;
-#if 1
- friend class LLCurl::Multi;
-#endif
-
- CURL* mCurlEasyHandle;
- struct curl_slist* mHeaders;
-
- std::stringstream mRequest;
- LLChannelDescriptors mChannels;
- LLIOPipe::buffer_ptr_t mOutput;
- std::stringstream mInput;
- std::stringstream mHeaderOutput;
- char mErrorBuffer[CURL_ERROR_SIZE];
-
- // Note: char*'s not strings since we pass pointers to curl
- std::vector mStrings;
-
- LLCurl::ResponderPtr mResponder;
-
- static std::set sFreeHandles;
- static std::set sActiveHandles;
- static LLMutex* sHandleMutexp ;
-
- static void deleteAllActiveHandles();
- static void deleteAllFreeHandles();
-};
-
-#if 1
-class LLCurl::Multi
-{
- LOG_CLASS(Multi);
-
- friend class LLCurlThread ;
-
-private:
- ~Multi();
-
- void markDead() ;
- bool doPerform();
-
-public:
-
- typedef enum
- {
- STATE_READY=0,
- STATE_PERFORMING=1,
- STATE_COMPLETED=2
- } ePerformState;
-
- Multi(F32 idle_time_out = 0.f);
-
- LLCurl::Easy* allocEasy();
- bool addEasy(LLCurl::Easy* easy);
- void removeEasy(LLCurl::Easy* easy);
-
- void lock() ;
- void unlock() ;
-
- void setState(ePerformState state) ;
- ePerformState getState() ;
-
- bool isCompleted() ;
- bool isValid() {return mCurlMultiHandle != NULL && mValid;}
- bool isDead() {return mDead;}
-
- bool waitToComplete() ;
-
- S32 process();
-
- CURLMsg* info_read(S32* msgs_in_queue);
-
- S32 mQueued;
- S32 mErrorCount;
-
-private:
- void easyFree(LLCurl::Easy*);
- void cleanup(bool deleted = false) ;
-
- CURLM* mCurlMultiHandle;
-
- typedef std::set easy_active_list_t;
- easy_active_list_t mEasyActiveList;
- typedef std::map easy_active_map_t;
- easy_active_map_t mEasyActiveMap;
- typedef std::set easy_free_list_t;
- easy_free_list_t mEasyFreeList;
-
- LLQueuedThread::handle_t mHandle ;
- ePerformState mState;
-
- BOOL mDead ;
- BOOL mValid ;
- LLMutex* mMutexp ;
- LLMutex* mDeletionMutexp ;
- LLMutex* mEasyMutexp ;
- LLFrameTimer mIdleTimer ;
- F32 mIdleTimeOut;
-};
-#endif
-
-#if 1
-class LLCurlThread : public LLQueuedThread
-{
-public:
-
- class CurlRequest : public LLQueuedThread::QueuedRequest
- {
- protected:
- virtual ~CurlRequest(); // use deleteRequest()
-
- public:
- CurlRequest(handle_t handle, LLCurl::Multi* multi, LLCurlThread* curl_thread);
-
- /*virtual*/ bool processRequest();
- /*virtual*/ void finishRequest(bool completed);
-
- private:
- // input
- LLCurl::Multi* mMulti;
- LLCurlThread* mCurlThread;
- };
- friend class CurlRequest;
-
-public:
- LLCurlThread(bool threaded = true) ;
- virtual ~LLCurlThread() ;
-
- S32 update(F32 max_time_ms);
-
- void addMulti(LLCurl::Multi* multi) ;
- void killMulti(LLCurl::Multi* multi) ;
-
-private:
- bool doMultiPerform(LLCurl::Multi* multi) ;
- void deleteMulti(LLCurl::Multi* multi) ;
- void cleanupMulti(LLCurl::Multi* multi) ;
-} ;
-#endif
-
-
-class LLCurlEasyRequest
-{
-public:
- LLCurlEasyRequest();
- ~LLCurlEasyRequest();
- void setopt(CURLoption option, S32 value);
- void setoptString(CURLoption option, const std::string& value);
- void setPost(char* postdata, S32 size);
- void setHeaderCallback(curl_header_callback callback, void* userdata);
- void setWriteCallback(curl_write_callback callback, void* userdata);
- void setReadCallback(curl_read_callback callback, void* userdata);
- void setSSLCtxCallback(curl_ssl_ctx_callback callback, void* userdata);
- void slist_append(const std::string& header, const std::string& value);
- void slist_append(const char* str);
- void sendRequest(const std::string& url);
- void requestComplete();
- bool getResult(CURLcode* result, LLCurl::TransferInfo* info = NULL);
- std::string getErrorString();
-#if 0
- bool isCompleted() { return false; }
- bool wait() { return false; }
- bool isValid() { return false; }
-#else
- bool isCompleted() {return mMulti->isCompleted() ;}
- bool wait() { return mMulti->waitToComplete(); }
- bool isValid() {return mMulti && mMulti->isValid(); }
-#endif
- LLCurl::Easy* getEasy() const { return mEasy; }
-
-private:
- CURLMsg* info_read(S32* queue, LLCurl::TransferInfo* info);
-
-private:
-#if 1
- LLCurl::Multi* mMulti;
-#endif
- LLCurl::Easy* mEasy;
- bool mRequestSent;
- bool mResultReturned;
-};
// Provide access to LLCurl free functions outside of llcurl.cpp without polluting the global namespace.
namespace LLCurlFF
diff --git a/indra/llmessage/llproxy.cpp b/indra/llmessage/llproxy.cpp
index 9b8d19cc3e..c25f1ec5e5 100755
--- a/indra/llmessage/llproxy.cpp
+++ b/indra/llmessage/llproxy.cpp
@@ -408,16 +408,6 @@ void LLProxy::cleanupClass()
deleteSingleton();
}
-void LLProxy::applyProxySettings(LLCurlEasyRequest* handle)
-{
- applyProxySettings(handle->getEasy());
-}
-
-void LLProxy::applyProxySettings(LLCurl::Easy* handle)
-{
- applyProxySettings(handle->getCurlHandle());
-}
-
/**
* @brief Apply proxy settings to a CuRL request if an HTTP proxy is enabled.
*
diff --git a/indra/llmessage/llproxy.h b/indra/llmessage/llproxy.h
index a919370540..da965219fa 100755
--- a/indra/llmessage/llproxy.h
+++ b/indra/llmessage/llproxy.h
@@ -208,16 +208,13 @@ enum LLSocks5AuthType
* thread-safe method to apply those options to a curl request
* (LLProxy::applyProxySettings()). This method is overloaded
* to accommodate the various abstraction libcurl layers that exist
- * throughout the viewer (LLCurlEasyRequest, LLCurl::Easy, and CURL).
- *
- * If you are working with LLCurl or LLCurlEasyRequest objects,
- * the configured proxy settings will be applied in the constructors
- * of those request handles. If you are working with CURL objects
- * directly, you will need to pass the handle of the request to
- * applyProxySettings() before issuing the request.
+ * throughout the viewer (CURL).
*
* To ensure thread safety, all LLProxy members that relate to the HTTP
* proxy require the LLProxyMutex to be locked before accessing.
+ *
+ * *TODO$: This should be moved into the LLCore::Http space.
+ *
*/
class LLProxy: public LLSingleton
{
@@ -252,9 +249,6 @@ public:
// Apply the current proxy settings to a curl request. Doesn't do anything if mHTTPProxyEnabled is false.
// Safe to call from any thread.
void applyProxySettings(CURL* handle);
- void applyProxySettings(LLCurl::Easy* handle);
- void applyProxySettings(LLCurlEasyRequest* handle);
-
// Start a connection to the SOCKS 5 proxy. Call from main thread only.
S32 startSOCKSProxy(LLHost host);
diff --git a/indra/llmessage/llsdrpcclient.cpp b/indra/llmessage/llsdrpcclient.cpp
deleted file mode 100755
index bb4739f733..0000000000
--- a/indra/llmessage/llsdrpcclient.cpp
+++ /dev/null
@@ -1,249 +0,0 @@
-/**
- * @file llsdrpcclient.cpp
- * @author Phoenix
- * @date 2005-11-05
- * @brief Implementation of the llsd client classes.
- *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-#include "llsdrpcclient.h"
-
-#include "llbufferstream.h"
-#include "llfasttimer.h"
-#include "llfiltersd2xmlrpc.h"
-#include "llpumpio.h"
-#include "llsd.h"
-#include "llsdserialize.h"
-#include "llurlrequest.h"
-
-/**
- * String constants
- */
-static std::string LLSDRPC_RESPONSE_NAME("response");
-static std::string LLSDRPC_FAULT_NAME("fault");
-
-#if 0
-/**
- * LLSDRPCResponse
- */
-LLSDRPCResponse::LLSDRPCResponse() :
- mIsError(false),
- mIsFault(false)
-{
-}
-
-// virtual
-LLSDRPCResponse::~LLSDRPCResponse()
-{
-}
-
-bool LLSDRPCResponse::extractResponse(const LLSD& sd)
-{
- bool rv = true;
- if(sd.has(LLSDRPC_RESPONSE_NAME))
- {
- mReturnValue = sd[LLSDRPC_RESPONSE_NAME];
- mIsFault = false;
- }
- else if(sd.has(LLSDRPC_FAULT_NAME))
- {
- mReturnValue = sd[LLSDRPC_FAULT_NAME];
- mIsFault = true;
- }
- else
- {
- mReturnValue.clear();
- mIsError = true;
- rv = false;
- }
- return rv;
-}
-
-static LLTrace::BlockTimerStatHandle FTM_SDRPC_RESPONSE("SDRPC Response");
-
-// virtual
-LLIOPipe::EStatus LLSDRPCResponse::process_impl(
- const LLChannelDescriptors& channels,
- buffer_ptr_t& buffer,
- bool& eos,
- LLSD& context,
- LLPumpIO* pump)
-{
- LL_RECORD_BLOCK_TIME(FTM_SDRPC_RESPONSE);
- PUMP_DEBUG;
- if(mIsError)
- {
- error(pump);
- }
- else if(mIsFault)
- {
- fault(pump);
- }
- else
- {
- response(pump);
- }
- PUMP_DEBUG;
- return STATUS_DONE;
-}
-#endif
-
-#if 0
-/**
- * LLSDRPCClient
- */
-
-LLSDRPCClient::LLSDRPCClient() :
- mState(STATE_NONE),
- mQueue(EPBQ_PROCESS)
-{
-}
-
-// virtual
-LLSDRPCClient::~LLSDRPCClient()
-{
-}
-
-bool LLSDRPCClient::call(
- const std::string& uri,
- const std::string& method,
- const LLSD& parameter,
- LLSDRPCResponse* response,
- EPassBackQueue queue)
-{
- //LL_INFOS() << "RPC: " << uri << "." << method << "(" << *parameter << ")"
- // << LL_ENDL;
- if(method.empty() || !response)
- {
- return false;
- }
- mState = STATE_READY;
- mURI.assign(uri);
- std::stringstream req;
- req << LLSDRPC_REQUEST_HEADER_1 << method
- << LLSDRPC_REQUEST_HEADER_2;
- LLSDSerialize::toNotation(parameter, req);
- req << LLSDRPC_REQUEST_FOOTER;
- mRequest = req.str();
- mQueue = queue;
- mResponse = response;
- return true;
-}
-
-bool LLSDRPCClient::call(
- const std::string& uri,
- const std::string& method,
- const std::string& parameter,
- LLSDRPCResponse* response,
- EPassBackQueue queue)
-{
- //LL_INFOS() << "RPC: " << uri << "." << method << "(" << parameter << ")"
- // << LL_ENDL;
- if(method.empty() || parameter.empty() || !response)
- {
- return false;
- }
- mState = STATE_READY;
- mURI.assign(uri);
- std::stringstream req;
- req << LLSDRPC_REQUEST_HEADER_1 << method
- << LLSDRPC_REQUEST_HEADER_2 << parameter
- << LLSDRPC_REQUEST_FOOTER;
- mRequest = req.str();
- mQueue = queue;
- mResponse = response;
- return true;
-}
-
-static LLTrace::BlockTimerStatHandle FTM_PROCESS_SDRPC_CLIENT("SDRPC Client");
-
-// virtual
-LLIOPipe::EStatus LLSDRPCClient::process_impl(
- const LLChannelDescriptors& channels,
- buffer_ptr_t& buffer,
- bool& eos,
- LLSD& context,
- LLPumpIO* pump)
-{
- LL_RECORD_BLOCK_TIME(FTM_PROCESS_SDRPC_CLIENT);
- PUMP_DEBUG;
- if((STATE_NONE == mState) || (!pump))
- {
- // You should have called the call() method already.
- return STATUS_PRECONDITION_NOT_MET;
- }
- EStatus rv = STATUS_DONE;
- switch(mState)
- {
- case STATE_READY:
- {
- PUMP_DEBUG;
-// LL_DEBUGS() << "LLSDRPCClient::process_impl STATE_READY" << LL_ENDL;
- buffer->append(
- channels.out(),
- (U8*)mRequest.c_str(),
- mRequest.length());
- context[CONTEXT_DEST_URI_SD_LABEL] = mURI;
- mState = STATE_WAITING_FOR_RESPONSE;
- break;
- }
- case STATE_WAITING_FOR_RESPONSE:
- {
- PUMP_DEBUG;
- // The input channel has the sd response in it.
- //LL_DEBUGS() << "LLSDRPCClient::process_impl STATE_WAITING_FOR_RESPONSE"
- // << LL_ENDL;
- LLBufferStream resp(channels, buffer.get());
- LLSD sd;
- LLSDSerialize::fromNotation(sd, resp, buffer->count(channels.in()));
- LLSDRPCResponse* response = (LLSDRPCResponse*)mResponse.get();
- if (!response)
- {
- mState = STATE_DONE;
- break;
- }
- response->extractResponse(sd);
- if(EPBQ_PROCESS == mQueue)
- {
- LLPumpIO::chain_t chain;
- chain.push_back(mResponse);
- pump->addChain(chain, DEFAULT_CHAIN_EXPIRY_SECS);
- }
- else
- {
- pump->respond(mResponse.get());
- }
- mState = STATE_DONE;
- break;
- }
- case STATE_DONE:
- default:
- PUMP_DEBUG;
- LL_INFOS() << "invalid state to process" << LL_ENDL;
- rv = STATUS_ERROR;
- break;
- }
- return rv;
-}
-#endif
diff --git a/indra/llmessage/llsdrpcclient.h b/indra/llmessage/llsdrpcclient.h
deleted file mode 100755
index c22051094d..0000000000
--- a/indra/llmessage/llsdrpcclient.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * @file llsdrpcclient.h
- * @author Phoenix
- * @date 2005-11-05
- * @brief Implementation and helpers for structure data RPC clients.
- *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLSDRPCCLIENT_H
-#define LL_LLSDRPCCLIENT_H
-
-/**
- * This file declares classes to encapsulate a basic structured data
- * remote procedure client.
- */
-
-#include "llchainio.h"
-#include "llfiltersd2xmlrpc.h"
-#include "lliopipe.h"
-#if 0
-//#include "llurlrequest.h"
-#endif
-
-#if 0
-/**
- * @class LLSDRPCClientResponse
- * @brief Abstract base class to represent a response from an SD server.
- *
- * This is used as a base class for callbacks generated from an
- * structured data remote procedure call. The
- * extractResponse method will deal with the llsdrpc method
- * call overhead, and keep track of what to call during the next call
- * into process. If you use this as a base class, you
- * need to implement response, fault, and
- * error to do something useful. When in those methods,
- * you can parse and utilize the mReturnValue member data.
- */
-class LLSDRPCResponse : public LLIOPipe
-{
-public:
- LLSDRPCResponse();
- virtual ~LLSDRPCResponse();
-
- /**
- * @brief This method extracts the response out of the sd passed in
- *
- * Any appropriate data found in the sd passed in will be
- * extracted and managed by this object - not copied or cloned. It
- * will still be up to the caller to delete the pointer passed in.
- * @param sd The raw structured data response from the remote server.
- * @return Returns true if this was able to parse the structured data.
- */
- bool extractResponse(const LLSD& sd);
-
-protected:
- /**
- * @brief Method called when the response is ready.
- */
- virtual bool response(LLPumpIO* pump) = 0;
-
- /**
- * @brief Method called when a fault is generated by the remote server.
- */
- virtual bool fault(LLPumpIO* pump) = 0;
-
- /**
- * @brief Method called when there was an error
- */
- virtual bool error(LLPumpIO* pump) = 0;
-
-protected:
- /* @name LLIOPipe virtual implementations
- */
- //@{
- /**
- * @brief Process the data in buffer
- */
- virtual EStatus process_impl(
- const LLChannelDescriptors& channels,
- buffer_ptr_t& buffer,
- bool& eos,
- LLSD& context,
- LLPumpIO* pump);
- //@}
-
-protected:
- LLSD mReturnValue;
- bool mIsError;
- bool mIsFault;
-};
-#endif
-
-#if 0
-/**
- * @class LLSDRPCClient
- * @brief Client class for a structured data remote procedure call.
- *
- * This class helps deal with making structured data calls to a remote
- * server. You can visualize the calls as:
- *
- * response = uri.method(parameter)
- *
- * where you pass in everything to call and this class
- * takes care of the rest of the details.
- * In typical usage, you will derive a class from this class and
- * provide an API more useful for the specific application at
- * hand. For example, if you were writing a service to send an instant
- * message, you could create an API for it to send the messsage, and
- * that class would do the work of translating it into the method and
- * parameter, find the destination, and invoke call with
- * a useful implementation of LLSDRPCResponse passed in to handle the
- * response from the network.
- */
-class LLSDRPCClient : public LLIOPipe
-{
-public:
- LLSDRPCClient();
- virtual ~LLSDRPCClient();
-
- /**
- * @brief Enumeration for tracking which queue to process the
- * response.
- */
- enum EPassBackQueue
- {
- EPBQ_PROCESS,
- EPBQ_CALLBACK,
- };
-
- /**
- * @brief Call a method on a remote LLSDRPCServer
- *
- * @param uri The remote object to call, eg,
- * http://localhost/usher. If you are using a factory with a fixed
- * url, the uri passed in will probably be ignored.
- * @param method The method to call on the remote object
- * @param parameter The parameter to pass into the remote
- * object. It is up to the caller to delete the value passed in.
- * @param response The object which gets the response.
- * @param queue Specifies to call the response on the process or
- * callback queue.
- * @return Returns true if this object will be able to make the RPC call.
- */
- bool call(
- const std::string& uri,
- const std::string& method,
- const LLSD& parameter,
- LLSDRPCResponse* response,
- EPassBackQueue queue);
-
- /**
- * @brief Call a method on a remote LLSDRPCServer
- *
- * @param uri The remote object to call, eg,
- * http://localhost/usher. If you are using a factory with a fixed
- * url, the uri passed in will probably be ignored.
- * @param method The method to call on the remote object
- * @param parameter The seriailized parameter to pass into the
- * remote object.
- * @param response The object which gets the response.
- * @param queue Specifies to call the response on the process or
- * callback queue.
- * @return Returns true if this object will be able to make the RPC call.
- */
- bool call(
- const std::string& uri,
- const std::string& method,
- const std::string& parameter,
- LLSDRPCResponse* response,
- EPassBackQueue queue);
-
-protected:
- /**
- * @brief Enumeration for tracking client state.
- */
- enum EState
- {
- STATE_NONE,
- STATE_READY,
- STATE_WAITING_FOR_RESPONSE,
- STATE_DONE
- };
-
- /* @name LLIOPipe virtual implementations
- */
- //@{
- /**
- * @brief Process the data in buffer
- */
- virtual EStatus process_impl(
- const LLChannelDescriptors& channels,
- buffer_ptr_t& buffer,
- bool& eos,
- LLSD& context,
- LLPumpIO* pump);
- //@}
-
-protected:
- EState mState;
- std::string mURI;
- std::string mRequest;
- EPassBackQueue mQueue;
- LLIOPipe::ptr_t mResponse;
-};
-#endif
-#endif // LL_LLSDRPCCLIENT_H
diff --git a/indra/llmessage/llsdrpcserver.cpp b/indra/llmessage/llsdrpcserver.cpp
deleted file mode 100755
index ac3f341d0f..0000000000
--- a/indra/llmessage/llsdrpcserver.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/**
- * @file llsdrpcserver.cpp
- * @author Phoenix
- * @date 2005-10-11
- * @brief Implementation of the LLSDRPCServer and related classes.
- *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "linden_common.h"
-#include "llsdrpcserver.h"
-
-#include "llbuffer.h"
-#include "llbufferstream.h"
-#include "llfasttimer.h"
-#include "llpumpio.h"
-#include "llsdserialize.h"
-#include "llstl.h"
-
-#if 0
-static const char FAULT_PART_1[] = "{'fault':{'code':i";
-static const char FAULT_PART_2[] = ", 'description':'";
-static const char FAULT_PART_3[] = "'}}";
-
-static const char RESPONSE_PART_1[] = "{'response':";
-static const char RESPONSE_PART_2[] = "}";
-
-static const S32 FAULT_GENERIC = 1000;
-static const S32 FAULT_METHOD_NOT_FOUND = 1001;
-
-static const std::string LLSDRPC_METHOD_SD_NAME("method");
-static const std::string LLSDRPC_PARAMETER_SD_NAME("parameter");
-
-
-/**
- * LLSDRPCServer
- */
-LLSDRPCServer::LLSDRPCServer() :
- mState(LLSDRPCServer::STATE_NONE),
- mPump(NULL),
- mLock(0)
-{
-}
-
-LLSDRPCServer::~LLSDRPCServer()
-{
- std::for_each(
- mMethods.begin(),
- mMethods.end(),
- llcompose1(
- DeletePointerFunctor(),
- llselect2nd()));
- std::for_each(
- mCallbackMethods.begin(),
- mCallbackMethods.end(),
- llcompose1(
- DeletePointerFunctor(),
- llselect2nd()));
-}
-
-
-// virtual
-ESDRPCSStatus LLSDRPCServer::deferredResponse(
- const LLChannelDescriptors& channels,
- LLBufferArray* data) {
- // subclass should provide a sane implementation
- return ESDRPCS_DONE;
-}
-
-void LLSDRPCServer::clearLock()
-{
- if(mLock && mPump)
- {
- mPump->clearLock(mLock);
- mPump = NULL;
- mLock = 0;
- }
-}
-
-static LLTrace::BlockTimerStatHandle FTM_PROCESS_SDRPC_SERVER("SDRPC Server");
-
-// virtual
-LLIOPipe::EStatus LLSDRPCServer::process_impl(
- const LLChannelDescriptors& channels,
- buffer_ptr_t& buffer,
- bool& eos,
- LLSD& context,
- LLPumpIO* pump)
-{
- LL_RECORD_BLOCK_TIME(FTM_PROCESS_SDRPC_SERVER);
- PUMP_DEBUG;
-// LL_DEBUGS() << "LLSDRPCServer::process_impl" << LL_ENDL;
- // Once we have all the data, We need to read the sd on
- // the the in channel, and respond on the out channel
- if(!eos) return STATUS_BREAK;
- if(!pump || !buffer) return STATUS_PRECONDITION_NOT_MET;
-
- std::string method_name;
- LLIOPipe::EStatus status = STATUS_DONE;
-
- switch(mState)
- {
- case STATE_DEFERRED:
- PUMP_DEBUG;
- if(ESDRPCS_DONE != deferredResponse(channels, buffer.get()))
- {
- buildFault(
- channels,
- buffer.get(),
- FAULT_GENERIC,
- "deferred response failed.");
- }
- mState = STATE_DONE;
- return STATUS_DONE;
-
- case STATE_DONE:
-// LL_DEBUGS() << "STATE_DONE" << LL_ENDL;
- break;
- case STATE_CALLBACK:
-// LL_DEBUGS() << "STATE_CALLBACK" << LL_ENDL;
- PUMP_DEBUG;
- method_name = mRequest[LLSDRPC_METHOD_SD_NAME].asString();
- if(!method_name.empty() && mRequest.has(LLSDRPC_PARAMETER_SD_NAME))
- {
- if(ESDRPCS_DONE != callbackMethod(
- method_name,
- mRequest[LLSDRPC_PARAMETER_SD_NAME],
- channels,
- buffer.get()))
- {
- buildFault(
- channels,
- buffer.get(),
- FAULT_GENERIC,
- "Callback method call failed.");
- }
- }
- else
- {
- // this should never happen, since we should not be in
- // this state unless we originally found a method and
- // params during the first call to process.
- buildFault(
- channels,
- buffer.get(),
- FAULT_GENERIC,
- "Invalid LLSDRPC sever state - callback without method.");
- }
- pump->clearLock(mLock);
- mLock = 0;
- mState = STATE_DONE;
- break;
- case STATE_NONE:
-// LL_DEBUGS() << "STATE_NONE" << LL_ENDL;
- default:
- {
- // First time we got here - process the SD request, and call
- // the method.
- PUMP_DEBUG;
- LLBufferStream istr(channels, buffer.get());
- mRequest.clear();
- LLSDSerialize::fromNotation(
- mRequest,
- istr,
- buffer->count(channels.in()));
-
- // { 'method':'...', 'parameter': ... }
- method_name = mRequest[LLSDRPC_METHOD_SD_NAME].asString();
- if(!method_name.empty() && mRequest.has(LLSDRPC_PARAMETER_SD_NAME))
- {
- ESDRPCSStatus rv = callMethod(
- method_name,
- mRequest[LLSDRPC_PARAMETER_SD_NAME],
- channels,
- buffer.get());
- switch(rv)
- {
- case ESDRPCS_DEFERRED:
- mPump = pump;
- mLock = pump->setLock();
- mState = STATE_DEFERRED;
- status = STATUS_BREAK;
- break;
-
- case ESDRPCS_CALLBACK:
- {
- mState = STATE_CALLBACK;
- LLPumpIO::LLLinkInfo link;
- link.mPipe = LLIOPipe::ptr_t(this);
- link.mChannels = channels;
- LLPumpIO::links_t links;
- links.push_back(link);
- pump->respond(links, buffer, context);
- mLock = pump->setLock();
- status = STATUS_BREAK;
- break;
- }
- case ESDRPCS_DONE:
- mState = STATE_DONE;
- break;
- case ESDRPCS_ERROR:
- default:
- buildFault(
- channels,
- buffer.get(),
- FAULT_GENERIC,
- "Method call failed.");
- break;
- }
- }
- else
- {
- // send a fault
- buildFault(
- channels,
- buffer.get(),
- FAULT_GENERIC,
- "Unable to find method and parameter in request.");
- }
- break;
- }
- }
-
- PUMP_DEBUG;
- return status;
-}
-
-// virtual
-ESDRPCSStatus LLSDRPCServer::callMethod(
- const std::string& method,
- const LLSD& params,
- const LLChannelDescriptors& channels,
- LLBufferArray* response)
-{
- // Try to find the method in the method table.
- ESDRPCSStatus rv = ESDRPCS_DONE;
- method_map_t::iterator it = mMethods.find(method);
- if(it != mMethods.end())
- {
- rv = (*it).second->call(params, channels, response);
- }
- else
- {
- it = mCallbackMethods.find(method);
- if(it == mCallbackMethods.end())
- {
- // method not found.
- std::ostringstream message;
- message << "rpc server unable to find method: " << method;
- buildFault(
- channels,
- response,
- FAULT_METHOD_NOT_FOUND,
- message.str());
- }
- else
- {
- // we found it in the callback methods - tell the process
- // to coordinate calling on the pump callback.
- return ESDRPCS_CALLBACK;
- }
- }
- return rv;
-}
-
-// virtual
-ESDRPCSStatus LLSDRPCServer::callbackMethod(
- const std::string& method,
- const LLSD& params,
- const LLChannelDescriptors& channels,
- LLBufferArray* response)
-{
- // Try to find the method in the callback method table.
- ESDRPCSStatus rv = ESDRPCS_DONE;
- method_map_t::iterator it = mCallbackMethods.find(method);
- if(it != mCallbackMethods.end())
- {
- rv = (*it).second->call(params, channels, response);
- }
- else
- {
- std::ostringstream message;
- message << "pcserver unable to find callback method: " << method;
- buildFault(
- channels,
- response,
- FAULT_METHOD_NOT_FOUND,
- message.str());
- }
- return rv;
-}
-
-// static
-void LLSDRPCServer::buildFault(
- const LLChannelDescriptors& channels,
- LLBufferArray* data,
- S32 code,
- const std::string& msg)
-{
- LLBufferStream ostr(channels, data);
- ostr << FAULT_PART_1 << code << FAULT_PART_2 << msg << FAULT_PART_3;
- LL_INFOS() << "LLSDRPCServer::buildFault: " << code << ", " << msg << LL_ENDL;
-}
-
-// static
-void LLSDRPCServer::buildResponse(
- const LLChannelDescriptors& channels,
- LLBufferArray* data,
- const LLSD& response)
-{
- LLBufferStream ostr(channels, data);
- ostr << RESPONSE_PART_1;
- LLSDSerialize::toNotation(response, ostr);
- ostr << RESPONSE_PART_2;
-#if LL_DEBUG
- std::ostringstream debug_ostr;
- debug_ostr << "LLSDRPCServer::buildResponse: ";
- LLSDSerialize::toNotation(response, debug_ostr);
- LL_INFOS() << debug_ostr.str() << LL_ENDL;
-#endif
-}
-#endif
diff --git a/indra/llmessage/llsdrpcserver.h b/indra/llmessage/llsdrpcserver.h
deleted file mode 100755
index 07d7b58b31..0000000000
--- a/indra/llmessage/llsdrpcserver.h
+++ /dev/null
@@ -1,361 +0,0 @@
-/**
- * @file llsdrpcserver.h
- * @author Phoenix
- * @date 2005-10-11
- * @brief Declaration of the structured data remote procedure call server.
- *
- * $LicenseInfo:firstyear=2005&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#ifndef LL_LLSDRPCSERVER_H
-#define LL_LLSDRPCSERVER_H
-
-#if 0
-/**
- * I've set this up to be pretty easy to use when you want to make a
- * structured data rpc server which responds to methods by
- * name. Derive a class from the LLSDRPCServer, and during
- * construction (or initialization if you have the luxury) map method
- * names to pointers to member functions. This will look a lot like:
- *
- *
- * class LLMessageAgents : public LLSDRPCServer {
- * public:
- * typedef LLSDRPCServer mem_fn_t;
- * LLMessageAgents() {
- * mMethods["message"] = new mem_fn_t(this, &LLMessageAgents::rpc_IM);
- * mMethods["alert"] = new mem_fn_t(this, &LLMessageAgents::rpc_Alrt);
- * }
- * protected:
- * rpc_IM(const LLSD& params,
- * const LLChannelDescriptors& channels,
- * LLBufferArray* data)
- * {...}
- * rpc_Alert(const LLSD& params,
- * const LLChannelDescriptors& channels,
- * LLBufferArray* data)
- * {...}
- * };
- *
- *
- * The params are an array where each element in the array is a single
- * parameter in the call.
- *
- * It is up to you to pack a valid serialized llsd response into the
- * data object passed into the method, but you can use the helper
- * methods below to help.
- */
-
-#include