diff options
Diffstat (limited to 'indra/llmessage/llcorehttputil.cpp')
-rw-r--r-- | indra/llmessage/llcorehttputil.cpp | 333 |
1 files changed, 255 insertions, 78 deletions
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index d342888255..9a23ede81b 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -35,7 +35,8 @@ #include "llsd.h" #include "llsdjson.h" #include "llsdserialize.h" -#include "reader.h" +#include "reader.h" // JSON +#include "writer.h" // JSON #include "llvfile.h" #include "message.h" // for getting the port @@ -45,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; @@ -104,7 +109,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, const LLSD & body, const HttpOptions::ptr_t &options, const HttpHeaders::ptr_t &headers, - HttpHandler * handler) + const HttpHandler::ptr_t &handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -131,7 +136,7 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, const LLSD & body, const HttpOptions::ptr_t &options, const HttpHeaders::ptr_t &headers, - HttpHandler * handler) + const HttpHandler::ptr_t &handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -157,7 +162,7 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, const LLSD & body, const HttpOptions::ptr_t &options, const HttpHeaders::ptr_t &headers, - HttpHandler * handler) + const HttpHandler::ptr_t &handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -243,13 +248,32 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons if (!status) { + bool parseSuccess(false); result = LLSD::emptyMap(); + LLCore::HttpStatus::type_enum_t errType = status.getType(); + LL_WARNS() << "\n--------------------------------------------------------------------------\n" - << " Error[" << status.getType() << "] cannot access url '" << response->getRequestURL() + << " Error[" << status.toTerseString() << "] cannot access url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; + if ((errType >= 400) && (errType < 500)) + { + LLSD body = this->parseBody(response, parseSuccess); + if (!body.isUndefined()) + { + if (!body.isMap()) + { + result[HttpCoroutineAdapter::HTTP_RESULTS_CONTENT] = body; + } + else + { + result = body; + } + } + + } } else { @@ -258,8 +282,6 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons buildStatusEntry(response, status, result); -#if 1 - // commenting out, but keeping since this can be useful for debugging if (!status) { LLSD &httpStatus = result[HttpCoroutineAdapter::HTTP_RESULTS]; @@ -271,10 +293,11 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons bas >> std::noskipws; bodyData.assign(std::istream_iterator<U8>(bas), std::istream_iterator<U8>()); httpStatus["error_body"] = LLSD(bodyData); - +#if 1 + // commenting out, but keeping since this can be useful for debugging LL_WARNS() << "Returned body=" << std::endl << httpStatus["error_body"].asString() << LL_ENDL; - } #endif + } mReplyPump.post(result); } @@ -340,6 +363,7 @@ public: protected: virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); + virtual LLSD parseBody(LLCore::HttpResponse *response, bool &success); }; //------------------------------------------------------------------------- @@ -353,8 +377,12 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: { LLSD result; - const bool emit_parse_errors = false; +// const bool emit_parse_errors = false; + bool success(false); + result = parseBody(response, success); + +#if 0 bool parsed = !((response->getBodySize() == 0) || !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, result)); @@ -374,9 +402,26 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: status = LLCore::HttpStatus(499, "Failed to deserialize LLSD."); } } +#endif - if (result.isUndefined()) - { // If we've gotten to this point and the result LLSD is still undefined + 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()); + const std::string *contentType = (headers) ? headers->find(HTTP_IN_HEADER_CONTENT_TYPE) : NULL; + + if (contentType && (HTTP_CONTENT_LLSD_XML == *contentType)) + { + std::string thebody = LLCoreHttpUtil::responseToString(response); + LL_WARNS() << "Failed to deserialize . " << response->getRequestURL() << " [status:" << response->getStatus().toString() << "] " + << " body: " << thebody << LL_ENDL; + + // Replace the status with a new one indicating the failure. + status = LLCore::HttpStatus(499, "Failed to deserialize LLSD."); + } +#endif + // 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(); @@ -393,6 +438,24 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: return result; } +LLSD HttpCoroLLSDHandler::parseBody(LLCore::HttpResponse *response, bool &success) +{ + success = true; + if (response->getBodySize() == 0) + return LLSD(); + + LLSD result; + + if (!LLCoreHttpUtil::responseToLLSD(response, true, result)) + { + success = false; + return LLSD(); + } + + return result; +} + + //======================================================================== /// The HttpCoroRawHandler is a specialization of the LLCore::HttpHandler for /// interacting with coroutines. @@ -407,6 +470,7 @@ public: HttpCoroRawHandler(LLEventStream &reply); virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); + virtual LLSD parseBody(LLCore::HttpResponse *response, bool &success); }; //------------------------------------------------------------------------- @@ -461,6 +525,12 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: return result; } +LLSD HttpCoroRawHandler::parseBody(LLCore::HttpResponse *response, bool &success) +{ + success = true; + return LLSD(); +} + //======================================================================== /// The HttpCoroJSONHandler is a specialization of the LLCore::HttpHandler for /// interacting with coroutines. @@ -475,6 +545,7 @@ public: HttpCoroJSONHandler(LLEventStream &reply); virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); + virtual LLSD parseBody(LLCore::HttpResponse *response, bool &success); }; //------------------------------------------------------------------------- @@ -512,6 +583,31 @@ LLSD HttpCoroJSONHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: return result; } +LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response, bool &success) +{ + success = true; + BufferArray * body(response->getBody()); + if (!body || !body->size()) + { + return LLSD(); + } + + LLCore::BufferArrayStream bas(body); + Json::Value jsonRoot; + + try + { + bas >> jsonRoot; + } + catch (std::runtime_error e) + { + success = false; + return LLSD(); + } + + // Convert the JSON structure to LLSD + return LlsdFromJson(jsonRoot); +} //======================================================================== HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request) : @@ -562,20 +658,20 @@ HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, HttpCoroutineAdapter::~HttpCoroutineAdapter() { - cancelYieldingOperation(); + cancelSuspendedOperation(); } -LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump)); - return postAndYield_(request, url, body, options, headers, httpHandler); + return postAndSuspend_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndSuspend_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -588,7 +684,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPostWithLLSD(request, mPolicyId, mPriority, url, body, options, headers, - handler.get()); + handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -596,35 +692,35 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::suspendUntilEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump)); - return postAndYield_(request, url, rawbody, options, headers, httpHandler); + return postAndSuspend_(request, url, rawbody, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postRawAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postRawAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::BufferArray::ptr_t rawbody, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroRawHandler(replyPump)); - return postAndYield_(request, url, rawbody, options, headers, httpHandler); + return postAndSuspend_(request, url, rawbody, options, headers, httpHandler); } // *TODO: This functionality could be moved into the LLCore::Http library itself // by having the CURL layer read the file directly. -LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -648,12 +744,12 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, } } - return postAndYield(request, url, fileData, options, headers); + return postAndSuspend(request, url, fileData, options, headers); } // *TODO: This functionality could be moved into the LLCore::Http library itself // by having the CURL layer read the file directly. -LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -673,11 +769,33 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, delete[] fileBuffer; } - return postAndYield(request, url, fileData, options, headers); + return postAndSuspend(request, url, fileData, options, headers); } +LLSD HttpCoroutineAdapter::postJsonAndSuspend(LLCore::HttpRequest::ptr_t request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName, true); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroJSONHandler(replyPump)); + + LLCore::BufferArray::ptr_t rawbody(new LLCore::BufferArray); + + { + LLCore::BufferArrayStream outs(rawbody.get()); + Json::Value root = LlsdToJson(body); + Json::FastWriter writer; + + LL_WARNS("Http::post") << "JSON Generates: \"" << writer.write(root) << "\"" << LL_ENDL; + + outs << writer.write(root); + } + + return postAndSuspend_(request, url, rawbody, options, headers, httpHandler); +} -LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, + +LLSD HttpCoroutineAdapter::postAndSuspend_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -689,7 +807,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, // 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, mPriority, url, rawbody.get(), - options, headers, handler.get()); + options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -697,23 +815,44 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::suspendUntilEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::putAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::putAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump)); - return putAndYield_(request, url, body, options, headers, httpHandler); + return putAndSuspend_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::putJsonAndSuspend(LLCore::HttpRequest::ptr_t request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName, true); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroJSONHandler(replyPump)); + + LLCore::BufferArray::ptr_t rawbody(new LLCore::BufferArray); + + { + LLCore::BufferArrayStream outs(rawbody.get()); + Json::Value root = LlsdToJson(body); + Json::FastWriter writer; + + LL_WARNS("Http::put") << "JSON Generates: \"" << writer.write(root) << "\"" << LL_ENDL; + outs << writer.write(root); + } + + return putAndSuspend_(request, url, rawbody, options, headers, httpHandler); +} + +LLSD HttpCoroutineAdapter::putAndSuspend_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -726,7 +865,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPutWithLLSD(request, mPolicyId, mPriority, url, body, options, headers, - handler.get()); + handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -734,43 +873,70 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::suspendUntilEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::getAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::putAndSuspend_(LLCore::HttpRequest::ptr_t &request, + const std::string & url, const LLCore::BufferArray::ptr_t & rawbody, + 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 + // pointer from the smart pointer is safe in this case. + LLCore::HttpHandle hhandle = request->requestPut(mPolicyId, mPriority, + url, rawbody.get(), options, headers, handler); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); + } + + saveState(hhandle, request, handler); + LLSD results = llcoro::suspendUntilEventOn(handler->getReplyPump()); + cleanState(); + + return results; +} + + +LLSD HttpCoroutineAdapter::getAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump)); - return getAndYield_(request, url, options, headers, httpHandler); + return getAndSuspend_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getRawAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getRawAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroRawHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroRawHandler(replyPump)); - return getAndYield_(request, url, options, headers, httpHandler); + return getAndSuspend_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getJsonAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getJsonAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroJSONHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroJSONHandler(replyPump)); - return getAndYield_(request, url, options, headers, httpHandler); + return getAndSuspend_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getAndYield_(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, HttpCoroHandler::ptr_t &handler) @@ -781,7 +947,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, // 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, mPriority, - url, options, headers, handler.get()); + url, options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -789,24 +955,35 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::suspendUntilEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::deleteAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::deleteAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump)); - return deleteAndYield_(request, url, options, headers, httpHandler); + return deleteAndSuspend_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::deleteJsonAndSuspend(LLCore::HttpRequest::ptr_t request, + const std::string & url, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName + "Reply", true); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroJSONHandler(replyPump)); + + return deleteAndSuspend_(request, url, options, headers, httpHandler); +} + + +LLSD HttpCoroutineAdapter::deleteAndSuspend_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { @@ -816,7 +993,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, // 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, mPriority, - url, options, headers, handler.get()); + url, options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -824,24 +1001,24 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::suspendUntilEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::patchAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::patchAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump)); - return patchAndYield_(request, url, body, options, headers, httpHandler); + return patchAndSuspend_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::patchAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::patchAndSuspend_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -854,7 +1031,7 @@ LLSD HttpCoroutineAdapter::patchAndYield_(LLCore::HttpRequest::ptr_t &request, // pointer from the smart pointer is safe in this case. LLCore::HttpHandle hhandle = requestPatchWithLLSD(request, mPolicyId, mPriority, url, body, options, headers, - handler.get()); + handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -862,28 +1039,28 @@ LLSD HttpCoroutineAdapter::patchAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::suspendUntilEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::copyAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::copyAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, const std::string dest, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump)); if (!headers) headers.reset(new LLCore::HttpHeaders); headers->append(HTTP_OUT_HEADER_DESTINATION, dest); - return copyAndYield_(request, url, options, headers, httpHandler); + return copyAndSuspend_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::copyAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::copyAndSuspend_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -896,7 +1073,7 @@ LLSD HttpCoroutineAdapter::copyAndYield_(LLCore::HttpRequest::ptr_t &request, // pointer from the smart pointer is safe in this case. // LLCore::HttpHandle hhandle = request->requestCopy(mPolicyId, mPriority, url, - options, headers, handler.get()); + options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -904,28 +1081,28 @@ LLSD HttpCoroutineAdapter::copyAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::suspendUntilEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::moveAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::moveAndSuspend(LLCore::HttpRequest::ptr_t request, const std::string & url, const std::string dest, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler(new HttpCoroLLSDHandler(replyPump)); if (!headers) headers.reset(new LLCore::HttpHeaders); headers->append(HTTP_OUT_HEADER_DESTINATION, dest); - return moveAndYield_(request, url, options, headers, httpHandler); + return moveAndSuspend_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::moveAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::moveAndSuspend_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -938,7 +1115,7 @@ LLSD HttpCoroutineAdapter::moveAndYield_(LLCore::HttpRequest::ptr_t &request, // pointer from the smart pointer is safe in this case. // LLCore::HttpHandle hhandle = request->requestMove(mPolicyId, mPriority, url, - options, headers, handler.get()); + options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -946,7 +1123,7 @@ LLSD HttpCoroutineAdapter::moveAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::suspendUntilEventOn(handler->getReplyPump()); cleanState(); return results; @@ -973,7 +1150,7 @@ void HttpCoroutineAdapter::checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &heade } -void HttpCoroutineAdapter::cancelYieldingOperation() +void HttpCoroutineAdapter::cancelSuspendedOperation() { LLCore::HttpRequest::ptr_t request = mWeakRequest.lock(); HttpCoroHandler::ptr_t handler = mWeakHandler.lock(); @@ -981,7 +1158,7 @@ void HttpCoroutineAdapter::cancelYieldingOperation() { cleanState(); LL_INFOS() << "Canceling yielding request!" << LL_ENDL; - request->requestCancel(mYieldingHandle, handler.get()); + request->requestCancel(mYieldingHandle, handler); } } @@ -1058,7 +1235,7 @@ void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest:: LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts); + LLSD result = httpAdapter->getAndSuspend(httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -1109,7 +1286,7 @@ void HttpCoroutineAdapter::trivialPostCoro(std::string url, LLCore::HttpRequest: LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndSuspend(httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); |