summaryrefslogtreecommitdiff
path: root/indra/llmessage/llcorehttputil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llcorehttputil.cpp')
-rw-r--r--indra/llmessage/llcorehttputil.cpp122
1 files changed, 61 insertions, 61 deletions
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp
index 7619b46fed..684e96883f 100644
--- a/indra/llmessage/llcorehttputil.cpp
+++ b/indra/llmessage/llcorehttputil.cpp
@@ -1,4 +1,4 @@
-/**
+/**
* @file llcorehttputil.cpp
* @date 2014-08-25
* @brief Implementation of adapter and utility classes expanding the llcorehttp interfaces.
@@ -6,21 +6,21 @@
* $LicenseInfo:firstyear=2014&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2014, 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$
*/
@@ -48,7 +48,7 @@ namespace LLCoreHttpUtil
const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f;
-namespace
+namespace
{
const std::string HTTP_LOGBODY_KEY("HTTPLogBodyOnError");
@@ -87,9 +87,9 @@ void logMessageFail(std::string logAuth, std::string url, std::string message)
}
//=========================================================================
-/// The HttpRequestPumper is a utility class. When constructed it will poll the
+/// The HttpRequestPumper is a utility class. When constructed it will poll the
/// supplied HttpRequest once per frame until it is destroyed.
-///
+///
class HttpRequestPumper
{
public:
@@ -261,7 +261,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons
LLCore::HttpStatus status = response->getStatus();
if (status == LLCore::HttpStatus(LLCore::HttpStatus::LLCORE, LLCore::HE_HANDLE_NOT_FOUND))
- { // A response came in for a canceled request and we have not processed the
+ { // A response came in for a canceled request and we have not processed the
// cancel yet. Patience!
return;
}
@@ -273,9 +273,9 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons
LLCore::HttpStatus::type_enum_t errType = status.getType();
LL_INFOS()
- << "Possible failure [" << status.toTerseString() << "] cannot "<< response->getRequestMethod()
+ << "Possible failure [" << status.toTerseString() << "] cannot "<< response->getRequestMethod()
<< " url '" << response->getRequestURL()
- << "' because " << status.toString()
+ << "' because " << status.toString()
<< LL_ENDL;
if ((errType >= 400) && (errType < 500))
{
@@ -360,13 +360,13 @@ void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::str
}
//=========================================================================
-/// The HttpCoroLLSDHandler is a specialization of the LLCore::HttpHandler for
-/// interacting with coroutines. When the request is completed the response
+/// The HttpCoroLLSDHandler is a specialization of the LLCore::HttpHandler for
+/// interacting with coroutines. When the request is completed the response
/// will be posted onto the supplied Event Pump.
-///
+///
/// If the LLSD retrieved from through the HTTP connection is not in the form
/// of a LLSD::map it will be returned as in an llsd["content"] element.
-///
+///
/// The LLSD posted back to the coroutine will have the following additions:
/// llsd["http_result"] -+- ["message"] - An error message returned from the HTTP status
/// +- ["status"] - The status code associated with the HTTP call
@@ -374,7 +374,7 @@ void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::str
/// +- ["type"] - The LLCore::HttpStatus type associted with the HTTP call
/// +- ["url"] - The URL used to make the call.
/// +- ["headers"] - A map of name name value pairs with the HTTP headers.
-///
+///
class HttpCoroLLSDHandler : public HttpCoroHandler
{
public:
@@ -390,7 +390,7 @@ HttpCoroLLSDHandler::HttpCoroLLSDHandler(LLEventStream &reply):
HttpCoroHandler(reply)
{
}
-
+
LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status)
{
@@ -424,7 +424,7 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:
#endif
if (!success)
- {
+ {
#if 1
// Only emit a warning if we failed to parse when 'content-type' == 'application/llsd+xml'
LLCore::HttpHeaders::ptr_t headers(response->getHeaders());
@@ -440,13 +440,13 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:
status = LLCore::HttpStatus(499, "Failed to deserialize LLSD.");
}
#endif
- // If we've gotten to this point and the result LLSD is still undefined
+ // If we've gotten to this point and the result LLSD is still undefined
// either there was an issue deserializing the body or the response was
// blank. Create an empty map to hold the result either way.
result = LLSD::emptyMap();
}
else if (!result.isMap())
- { // The results are not themselves a map. Move them down so that
+ { // The results are not themselves a map. Move them down so that
// this method can return a map to the caller.
// *TODO: Should it always do this?
LLSD newResult = LLSD::emptyMap();
@@ -476,13 +476,13 @@ LLSD HttpCoroLLSDHandler::parseBody(LLCore::HttpResponse *response, bool &succes
//========================================================================
-/// The HttpCoroRawHandler is a specialization of the LLCore::HttpHandler for
-/// interacting with coroutines.
-///
-/// In addition to the normal "http_results" the returned LLSD will contain
+/// The HttpCoroRawHandler is a specialization of the LLCore::HttpHandler for
+/// interacting with coroutines.
+///
+/// In addition to the normal "http_results" the returned LLSD will contain
/// an entry keyed with "raw" containing the unprocessed results of the HTTP
/// call.
-///
+///
class HttpCoroRawHandler : public HttpCoroHandler
{
public:
@@ -515,9 +515,9 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::
#if 1
// This is the slower implementation. It is safe vis-a-vi the const_cast<> and modification
// of a LLSD managed array but contains an extra (potentially large) copy.
- //
+ //
// *TODO: https://jira.secondlife.com/browse/MAINT-5221
-
+
LLSD::Binary data;
data.reserve(size);
bas >> std::noskipws;
@@ -526,12 +526,12 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::
result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = data;
#else
- // This is disabled because it's dangerous. See the other case for an
+ // This is disabled because it's dangerous. See the other case for an
// alternate implementation.
// We create a new LLSD::Binary object and assign it to the result map.
- // The LLSD has created it's own copy so we retrieve it asBinary and const cast
+ // The LLSD has created it's own copy so we retrieve it asBinary and const cast
// the reference so that we can modify it.
- // *TODO: This is potentially dangerous... but I am trying to avoid a potentially
+ // *TODO: This is potentially dangerous... but I am trying to avoid a potentially
// large copy.
result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = LLSD::Binary();
LLSD::Binary &data = const_cast<LLSD::Binary &>( result[HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary() );
@@ -551,13 +551,13 @@ LLSD HttpCoroRawHandler::parseBody(LLCore::HttpResponse *response, bool &success
}
//========================================================================
-/// The HttpCoroJSONHandler is a specialization of the LLCore::HttpHandler for
-/// interacting with coroutines.
-///
-/// In addition to the normal "http_results" the returned LLSD will contain
-/// JSON entries will be converted into an LLSD map. All results are considered
+/// The HttpCoroJSONHandler is a specialization of the LLCore::HttpHandler for
+/// interacting with coroutines.
+///
+/// In addition to the normal "http_results" the returned LLSD will contain
+/// JSON entries will be converted into an LLSD map. All results are considered
/// strings
-///
+///
class HttpCoroJSONHandler : public HttpCoroHandler
{
public:
@@ -692,7 +692,7 @@ LLSD HttpCoroutineAdapter::postAndSuspend_(LLCore::HttpRequest::ptr_t &request,
checkDefaultHeaders(headers);
- // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = requestPostWithLLSD(request,
mPolicyId, url, body, options, headers,
@@ -730,7 +730,7 @@ LLSD HttpCoroutineAdapter::postRawAndSuspend(LLCore::HttpRequest::ptr_t request,
return postAndSuspend_(request, url, rawbody, options, headers, httpHandler);
}
-// *TODO: This functionality could be moved into the LLCore::Http library itself
+// *TODO: This functionality could be moved into the LLCore::Http library itself
// by having the CURL layer read the file directly.
LLSD HttpCoroutineAdapter::postFileAndSuspend(LLCore::HttpRequest::ptr_t request,
const std::string & url, std::string fileName,
@@ -759,7 +759,7 @@ LLSD HttpCoroutineAdapter::postFileAndSuspend(LLCore::HttpRequest::ptr_t request
return postAndSuspend(request, url, fileData, options, headers);
}
-// *TODO: This functionality could be moved into the LLCore::Http library itself
+// *TODO: This functionality could be moved into the LLCore::Http library itself
// by having the CURL layer read the file directly.
LLSD HttpCoroutineAdapter::postFileAndSuspend(LLCore::HttpRequest::ptr_t request,
const std::string & url, LLUUID assetId, LLAssetType::EType assetType,
@@ -776,7 +776,7 @@ LLSD HttpCoroutineAdapter::postFileAndSuspend(LLCore::HttpRequest::ptr_t request
U8* fileBuffer;
fileBuffer = new U8[fileSize];
vfile.read(fileBuffer, fileSize);
-
+
outs.write((char*)fileBuffer, fileSize);
delete[] fileBuffer;
}
@@ -816,7 +816,7 @@ LLSD HttpCoroutineAdapter::postAndSuspend_(LLCore::HttpRequest::ptr_t &request,
checkDefaultHeaders(headers);
- // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, url, rawbody.get(),
options, headers, handler);
@@ -873,7 +873,7 @@ LLSD HttpCoroutineAdapter::putAndSuspend_(LLCore::HttpRequest::ptr_t &request,
checkDefaultHeaders(headers);
- // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = requestPutWithLLSD(request,
mPolicyId, url, body, options, headers,
@@ -900,7 +900,7 @@ LLSD HttpCoroutineAdapter::putAndSuspend_(LLCore::HttpRequest::ptr_t &request,
checkDefaultHeaders(headers);
- // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestPut(mPolicyId,
url, rawbody.get(), options, headers, handler);
@@ -950,13 +950,13 @@ LLSD HttpCoroutineAdapter::getJsonAndSuspend(LLCore::HttpRequest::ptr_t request,
LLSD HttpCoroutineAdapter::getAndSuspend_(LLCore::HttpRequest::ptr_t &request,
const std::string & url,
- LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
+ LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
HttpCoroHandler::ptr_t &handler)
{
HttpRequestPumper pumper(request);
checkDefaultHeaders(headers);
- // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestGet(mPolicyId,
url, options, headers, handler);
@@ -985,7 +985,7 @@ LLSD HttpCoroutineAdapter::deleteAndSuspend(LLCore::HttpRequest::ptr_t request,
}
LLSD HttpCoroutineAdapter::deleteJsonAndSuspend(LLCore::HttpRequest::ptr_t request,
- const std::string & url,
+ const std::string & url,
LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers)
{
LLEventStream replyPump(mAdapterName + "Reply", true);
@@ -996,13 +996,13 @@ LLSD HttpCoroutineAdapter::deleteJsonAndSuspend(LLCore::HttpRequest::ptr_t reque
LLSD HttpCoroutineAdapter::deleteAndSuspend_(LLCore::HttpRequest::ptr_t &request,
- const std::string & url, LLCore::HttpOptions::ptr_t &options,
+ const std::string & url, LLCore::HttpOptions::ptr_t &options,
LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler)
{
HttpRequestPumper pumper(request);
checkDefaultHeaders(headers);
- // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId,
url, options, headers, handler);
@@ -1039,7 +1039,7 @@ LLSD HttpCoroutineAdapter::patchAndSuspend_(LLCore::HttpRequest::ptr_t &request,
checkDefaultHeaders(headers);
- // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = requestPatchWithLLSD(request,
mPolicyId, url, body, options, headers,
@@ -1073,7 +1073,7 @@ LLSD HttpCoroutineAdapter::copyAndSuspend(LLCore::HttpRequest::ptr_t request,
LLSD HttpCoroutineAdapter::copyAndSuspend_(LLCore::HttpRequest::ptr_t &request,
- const std::string & url,
+ const std::string & url,
LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers,
HttpCoroHandler::ptr_t &handler)
{
@@ -1081,9 +1081,9 @@ LLSD HttpCoroutineAdapter::copyAndSuspend_(LLCore::HttpRequest::ptr_t &request,
checkDefaultHeaders(headers);
- // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
- //
+ //
LLCore::HttpHandle hhandle = request->requestCopy(mPolicyId, url,
options, headers, handler);
@@ -1123,9 +1123,9 @@ LLSD HttpCoroutineAdapter::moveAndSuspend_(LLCore::HttpRequest::ptr_t &request,
checkDefaultHeaders(headers);
- // The HTTPCoroHandler does not self delete, so retrieval of a the contained
+ // The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
- //
+ //
LLCore::HttpHandle hhandle = request->requestMove(mPolicyId, url,
options, headers, handler);
@@ -1174,7 +1174,7 @@ void HttpCoroutineAdapter::cancelSuspendedOperation()
}
}
-void HttpCoroutineAdapter::saveState(LLCore::HttpHandle yieldingHandle,
+void HttpCoroutineAdapter::saveState(LLCore::HttpHandle yieldingHandle,
LLCore::HttpRequest::ptr_t &request, HttpCoroHandler::ptr_t &handler)
{
mWeakRequest = request;
@@ -1190,15 +1190,15 @@ void HttpCoroutineAdapter::cleanState()
}
/*static*/
-LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request,
- const std::string &url)
+LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request,
+ const std::string &url)
{
LLCore::HttpStatus status = request->getStatus();
LL_WARNS("CoreHTTP") << "Error posting to " << url << " Status=" << status.getStatus() <<
" message = " << status.getMessage() << LL_ENDL;
- // Mimic the status results returned from an http error that we had
- // to wait on
+ // Mimic the status results returned from an http error that we had
+ // to wait on
LLSD httpresults = LLSD::emptyMap();
HttpCoroHandler::writeStatusCodes(status, url, httpresults);
@@ -1228,7 +1228,7 @@ void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, LLCore::HttpR
/*static*/
void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::string &success, const std::string &failure)
{
- completionCallback_t cbSuccess = (success.empty()) ? NULL :
+ completionCallback_t cbSuccess = (success.empty()) ? NULL :
static_cast<completionCallback_t>(boost::bind(&logMessageSuccess, "HttpCoroutineAdapter", url, success));
completionCallback_t cbFailure = (failure.empty()) ? NULL :
static_cast<completionCallback_t>(boost::bind(&logMessageFail, "HttpCoroutineAdapter", url, failure));
@@ -1253,7 +1253,7 @@ void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest::
LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
if (!status)
- {
+ {
if (failure)
{
failure(httpResults);