diff options
author | Rider Linden <rider@lindenlab.com> | 2015-08-12 16:32:49 -0700 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2015-08-12 16:32:49 -0700 |
commit | 248d61fe0eadd128c7704e37922ba7fdef35d630 (patch) | |
tree | 47597f9a1d4a1a3dc774c9f10f3d6d74338c5322 /indra/llmessage | |
parent | 14a8c70867252926fdfc42728c1de38c8ef68706 (diff) |
MAINT-5500: Finish converting the AIS responders to the new coroutine model, Cleaned up dead an unused code.
MAINT-4952: Added COPY and MOVE methods to Core:Http adapter
Diffstat (limited to 'indra/llmessage')
-rw-r--r-- | indra/llmessage/llcorehttputil.cpp | 94 | ||||
-rw-r--r-- | indra/llmessage/llcorehttputil.h | 52 |
2 files changed, 140 insertions, 6 deletions
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 50c866f370..d342888255 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -700,7 +700,6 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } @@ -737,7 +736,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, saveState(hhandle, request, handler); LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; } @@ -792,7 +791,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, saveState(hhandle, request, handler); LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; } @@ -827,7 +826,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, saveState(hhandle, request, handler); LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; } @@ -865,10 +864,95 @@ LLSD HttpCoroutineAdapter::patchAndYield_(LLCore::HttpRequest::ptr_t &request, saveState(hhandle, request, handler); LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + + return results; +} + +LLSD HttpCoroutineAdapter::copyAndYield(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)); + + if (!headers) + headers.reset(new LLCore::HttpHeaders); + headers->append(HTTP_OUT_HEADER_DESTINATION, dest); + + return copyAndYield_(request, url, options, headers, httpHandler); +} + + +LLSD HttpCoroutineAdapter::copyAndYield_(LLCore::HttpRequest::ptr_t &request, + 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 + // pointer from the smart pointer is safe in this case. + // + LLCore::HttpHandle hhandle = request->requestCopy(mPolicyId, mPriority, url, + options, headers, handler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); + } + + saveState(hhandle, request, handler); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + cleanState(); + + return results; +} + +LLSD HttpCoroutineAdapter::moveAndYield(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)); + + if (!headers) + headers.reset(new LLCore::HttpHeaders); + headers->append(HTTP_OUT_HEADER_DESTINATION, dest); + + return moveAndYield_(request, url, options, headers, httpHandler); +} + + +LLSD HttpCoroutineAdapter::moveAndYield_(LLCore::HttpRequest::ptr_t &request, + 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 + // pointer from the smart pointer is safe in this case. + // + LLCore::HttpHandle hhandle = request->requestMove(mPolicyId, mPriority, url, + options, headers, handler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); + } + + saveState(hhandle, request, handler); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + cleanState(); + return results; } + void HttpCoroutineAdapter::checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers) { if (!headers) diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 8fe2354d6b..31a73bb900 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -457,7 +457,7 @@ public: LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - /// Execute a Post transaction on the supplied URL and yield execution of + /// Execute a PATCH transaction on the supplied URL and yield execution of /// the coroutine until a result is available. /// /// @Note: the request's smart pointer is passed by value so that it will @@ -474,6 +474,46 @@ public: LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } + /// Execute a COPY transaction on the supplied URL and yield execution of + /// the coroutine until a result is available. + /// + /// @Note: The destination is passed through the HTTP pipe as a header + /// The header used is defined as: HTTP_OUT_HEADER_DESTINATION("Destination"); + /// + /// @Note: the request's smart pointer is passed by value so that it will + /// not be deallocated during the yield. + LLSD copyAndYield(LLCore::HttpRequest::ptr_t request, + const std::string & url, const std::string dest, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); + LLSD copyAndYield(LLCore::HttpRequest::ptr_t &request, + const std::string & url, const std::string & dest, + LLCore::HttpHeaders::ptr_t &headers) + { + return copyAndYield(request, url, dest, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); + } + + /// Execute a MOVE transaction on the supplied URL and yield execution of + /// the coroutine until a result is available. + /// + /// @Note: The destination is passed through the HTTP pipe in the headers. + /// The header used is defined as: HTTP_OUT_HEADER_DESTINATION("Destination"); + /// + /// @Note: the request's smart pointer is passed by value so that it will + /// not be deallocated during the yield. + LLSD moveAndYield(LLCore::HttpRequest::ptr_t request, + const std::string & url, const std::string dest, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); + LLSD moveAndYield(LLCore::HttpRequest::ptr_t &request, + const std::string & url, const std::string & dest, + LLCore::HttpHeaders::ptr_t &headers) + { + return moveAndYield(request, url, dest, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); + } + /// void cancelYieldingOperation(); @@ -541,6 +581,16 @@ private: LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); + LLSD copyAndYield_(LLCore::HttpRequest::ptr_t &request, + const std::string & url, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler); + + LLSD moveAndYield_(LLCore::HttpRequest::ptr_t &request, + const std::string & url, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler); + static void trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure); static void trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure); |