From 6b8c814df3141fa705b9921ba0a73aeaa3fe63b6 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 19 Mar 2015 17:01:21 -0700 Subject: Adding new HTTP handling for material manager. --- indra/llmessage/llcorehttputil.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index ee80b0fd94..1a5a6fc75f 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -88,6 +88,32 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, return handle; } +HttpHandle requestPutWithLLSD(HttpRequest * request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * handler) +{ + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + BufferArray * ba = new BufferArray(); + BufferArrayStream bas(ba); + LLSDSerialize::toXML(body, bas); + + handle = request->requestPut(policy_id, + priority, + url, + ba, + options, + headers, + handler); + ba->release(); + return handle; +} + std::string responseToString(LLCore::HttpResponse * response) { -- cgit v1.2.3 From 9d676ce5b97d7ce09630d7d6ab8abd562b958cae Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 20 Mar 2015 13:16:25 -0700 Subject: Clean up and use policies for Material transfer. --- indra/llmessage/llcorehttputil.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 1a5a6fc75f..366a0b9460 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -88,6 +88,19 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, return handle; } +HttpHandle requestPostWithLLSD(HttpRequest::ptr_t & request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) +{ + return requestPostWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} + HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, @@ -114,6 +127,18 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, return handle; } +HttpHandle requestPutWithLLSD(HttpRequest::ptr_t & request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) +{ + return requestPutWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} std::string responseToString(LLCore::HttpResponse * response) { -- cgit v1.2.3 From edc1439bd633bdac183fbecc131edd55074b5442 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 1 Apr 2015 16:37:00 -0700 Subject: Added AvatarNameCache as coroutine, with LLCore::HttpHandler to respond correctly to Event Pumps. Added get/setRequestURL() to LLCore::HttpResponse Removed URI from the HttpSDHandler. --- indra/llmessage/llcorehttputil.cpp | 96 +++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 366a0b9460..991985b1cf 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -30,15 +30,17 @@ #include #include "llcorehttputil.h" +#include "llhttpconstants.h" #include "llsdserialize.h" - using namespace LLCore; namespace LLCoreHttpUtil { + + // *TODO: Currently converts only from XML content. A mode // to convert using fromBinary() might be useful as well. Mesh // headers could use it. @@ -186,5 +188,97 @@ std::string responseToString(LLCore::HttpResponse * response) } +HttpCoroHandler::HttpCoroHandler(LLEventStream &reply) : + mReplyPump(reply) +{ +} + +void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) +{ + LLSD result; + + LLCore::HttpStatus status = response->getStatus(); + + if (!status) + { + result = LLSD::emptyMap(); + LL_WARNS() + << "\n--------------------------------------------------------------------------\n" + << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL() + << "' because " << status.toString() + << "\n--------------------------------------------------------------------------" + << LL_ENDL; + + } + else + { + const bool emit_parse_errors = false; + + bool parsed = !((response->getBodySize() == 0) || + !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, result)); + + if (!parsed) + { + // 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."); + } + } + + if (result.isUndefined()) + { + // 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(); + } + } + + buildStatusEntry(response, status, result); + mReplyPump.post(result); +} + +void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::HttpStatus status, LLSD &result) +{ + LLSD httpresults = LLSD::emptyMap(); + + httpresults["success"] = static_cast(status); + httpresults["type"] = static_cast(status.getType()); + httpresults["status"] = static_cast(status.getStatus()); + httpresults["message"] = static_cast(status.getMessage()); + httpresults["url"] = static_cast(response->getRequestURL()); + + LLSD httpHeaders = LLSD::emptyMap(); + LLCore::HttpHeaders * hdrs = response->getHeaders(); + + if (hdrs) + { + for (LLCore::HttpHeaders::iterator it = hdrs->begin(); it != hdrs->end(); ++it) + { + if (!(*it).second.empty()) + { + httpHeaders[(*it).first] = (*it).second; + } + else + { + httpHeaders[(*it).first] = static_cast(true); + } + } + } + + httpresults["headers"] = httpHeaders; + result["http_result"] = httpresults; +} + + } // end namespace LLCoreHttpUtil -- cgit v1.2.3 From 17641c8427d05c4cde1fadd2ca059264d89bc818 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 3 Apr 2015 14:23:31 -0700 Subject: Added a class to automate pumping the HttpRequest on the mainloop. Converted AccountingCostManager to use the new LLCore::Http library and coroutines. --- indra/llmessage/llcorehttputil.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 991985b1cf..30f5f3d3ed 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -279,6 +279,27 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H result["http_result"] = httpresults; } +HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request): + mHttpRequest(request) +{ + mBoundListener = LLEventPumps::instance().obtain("mainloop"). + listen(LLEventPump::inventName(), boost::bind(&HttpRequestPumper::pollRequest, this, _1)); +} + +HttpRequestPumper::~HttpRequestPumper() +{ + if (mBoundListener.connected()) + { + mBoundListener.disconnect(); + } +} + +bool HttpRequestPumper::pollRequest(const LLSD&) +{ + mHttpRequest->update(0L); + return false; +} + } // end namespace LLCoreHttpUtil -- cgit v1.2.3 From 8a76284e488227b9ff83917cdec2ea011c088527 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Apr 2015 10:30:10 -0700 Subject: Results from code review with Nat. Consolidate some of the coroutine/http code into a single adapter. --- indra/llmessage/llcorehttputil.cpp | 422 ++++++++++++++++++++++++++----------- 1 file changed, 296 insertions(+), 126 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 30f5f3d3ed..882fef66bc 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -46,148 +46,148 @@ namespace LLCoreHttpUtil // headers could use it. bool responseToLLSD(HttpResponse * response, bool log, LLSD & out_llsd) { - // Convert response to LLSD - BufferArray * body(response->getBody()); - if (! body || ! body->size()) - { - return false; - } - - LLCore::BufferArrayStream bas(body); - LLSD body_llsd; - S32 parse_status(LLSDSerialize::fromXML(body_llsd, bas, log)); - if (LLSDParser::PARSE_FAILURE == parse_status){ - return false; - } - out_llsd = body_llsd; - return true; + // Convert response to LLSD + BufferArray * body(response->getBody()); + if (!body || !body->size()) + { + return false; + } + + LLCore::BufferArrayStream bas(body); + LLSD body_llsd; + S32 parse_status(LLSDSerialize::fromXML(body_llsd, bas, log)); + if (LLSDParser::PARSE_FAILURE == parse_status){ + return false; + } + out_llsd = body_llsd; + return true; } HttpHandle requestPostWithLLSD(HttpRequest * request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions * options, - HttpHeaders * headers, - HttpHandler * handler) + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * handler) { - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - - BufferArray * ba = new BufferArray(); - BufferArrayStream bas(ba); - LLSDSerialize::toXML(body, bas); - - handle = request->requestPost(policy_id, - priority, - url, - ba, - options, - headers, - handler); - ba->release(); - return handle; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + BufferArray * ba = new BufferArray(); + BufferArrayStream bas(ba); + LLSDSerialize::toXML(body, bas); + + handle = request->requestPost(policy_id, + priority, + url, + ba, + options, + headers, + handler); + ba->release(); + return handle; } HttpHandle requestPostWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) { - return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + return requestPostWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); } HttpHandle requestPutWithLLSD(HttpRequest * request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions * options, - HttpHeaders * headers, - HttpHandler * handler) + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * handler) { - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - - BufferArray * ba = new BufferArray(); - BufferArrayStream bas(ba); - LLSDSerialize::toXML(body, bas); - - handle = request->requestPut(policy_id, - priority, - url, - ba, - options, - headers, - handler); - ba->release(); - return handle; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + BufferArray * ba = new BufferArray(); + BufferArrayStream bas(ba); + LLSDSerialize::toXML(body, bas); + + handle = request->requestPut(policy_id, + priority, + url, + ba, + options, + headers, + handler); + ba->release(); + return handle; } HttpHandle requestPutWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) { - return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + return requestPutWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); } std::string responseToString(LLCore::HttpResponse * response) { - static const std::string empty("[Empty]"); - - if (! response) - { - return empty; - } - - BufferArray * body(response->getBody()); - if (! body || ! body->size()) - { - return empty; - } - - // Attempt to parse as LLSD regardless of content-type - LLSD body_llsd; - if (responseToLLSD(response, false, body_llsd)) - { - std::ostringstream tmp; - - LLSDSerialize::toPrettyNotation(body_llsd, tmp); - std::size_t temp_len(tmp.tellp()); - - if (temp_len) - { - return tmp.str().substr(0, std::min(temp_len, std::size_t(1024))); - } - } - else - { - // *TODO: More elaborate forms based on Content-Type as needed. - char content[1024]; - - size_t len(body->read(0, content, sizeof(content))); - if (len) - { - return std::string(content, 0, len); - } - } - - // Default - return empty; -} + static const std::string empty("[Empty]"); + + if (!response) + { + return empty; + } + + BufferArray * body(response->getBody()); + if (!body || !body->size()) + { + return empty; + } + + // Attempt to parse as LLSD regardless of content-type + LLSD body_llsd; + if (responseToLLSD(response, false, body_llsd)) + { + std::ostringstream tmp; + + LLSDSerialize::toPrettyNotation(body_llsd, tmp); + std::size_t temp_len(tmp.tellp()); + + if (temp_len) + { + return tmp.str().substr(0, std::min(temp_len, std::size_t(1024))); + } + } + else + { + // *TODO: More elaborate forms based on Content-Type as needed. + char content[1024]; + + size_t len(body->read(0, content, sizeof(content))); + if (len) + { + return std::string(content, 0, len); + } + } + // Default + return empty; +} +//======================================================================== HttpCoroHandler::HttpCoroHandler(LLEventStream &reply) : mReplyPump(reply) { @@ -204,7 +204,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons result = LLSD::emptyMap(); LL_WARNS() << "\n--------------------------------------------------------------------------\n" - << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL() + << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; @@ -251,11 +251,12 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H { LLSD httpresults = LLSD::emptyMap(); - httpresults["success"] = static_cast(status); - httpresults["type"] = static_cast(status.getType()); - httpresults["status"] = static_cast(status.getStatus()); - httpresults["message"] = static_cast(status.getMessage()); - httpresults["url"] = static_cast(response->getRequestURL()); + writeStatusCodes(status, response->getRequestURL(), httpresults); + // httpresults["success"] = static_cast(status); + // httpresults["type"] = static_cast(status.getType()); + // httpresults["status"] = static_cast(status.getStatus()); + // httpresults["message"] = static_cast(status.getMessage()); + // httpresults["url"] = static_cast(response->getRequestURL()); LLSD httpHeaders = LLSD::emptyMap(); LLCore::HttpHeaders * hdrs = response->getHeaders(); @@ -279,7 +280,18 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H result["http_result"] = httpresults; } -HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request): +void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::string &url, LLSD &result) +{ + result["success"] = static_cast(status); + result["type"] = static_cast(status.getType()); + result["status"] = static_cast(status.getStatus()); + result["message"] = static_cast(status.getMessage()); + result["url"] = static_cast(url); + +} + +//======================================================================== +HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request) : mHttpRequest(request) { mBoundListener = LLEventPumps::instance().obtain("mainloop"). @@ -300,6 +312,164 @@ bool HttpRequestPumper::pollRequest(const LLSD&) return false; } +//======================================================================== +HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, + LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority) : + mAdapterName(name), + mPolicyId(policyId), + mPriority(priority) +{ +} + +HttpCoroutineAdapter::~HttpCoroutineAdapter() +{ +} + +LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + if (!options) + { + options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + } + + if (!headers) + { + headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + } + + LLEventStream replyPump(mAdapterName, true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(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 = requestPostWithLLSD(request, + mPolicyId, mPriority, url, body, options, headers, + httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + LLCore::HttpStatus status = request->getStatus(); + LL_WARNS() << "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 + LLSD httpresults = LLSD::emptyMap(); + + httpHandler->writeStatusCodes(status, url, httpresults); + + LLSD errorres = LLSD::emptyMap(); + errorres["http_result"] = httpresults; + + return errorres; + } + + LLSD results = waitForEventOn(self, replyPump); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} + +LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + const std::string & url, const LLSD & body, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + if (!options) + { + options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + } + + if (!headers) + { + headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + } + + LLEventStream replyPump(mAdapterName, true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(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 = requestPutWithLLSD(request, + mPolicyId, mPriority, url, body, options, headers, + httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + LLCore::HttpStatus status = request->getStatus(); + LL_WARNS() << "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 + LLSD httpresults = LLSD::emptyMap(); + + httpHandler->writeStatusCodes(status, url, httpresults); + + LLSD errorres = LLSD::emptyMap(); + errorres["http_result"] = httpresults; + + return errorres; + } + + LLSD results = waitForEventOn(self, replyPump); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} + +LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, + const std::string & url, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + if (!options) + { + options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + } + + if (!headers) + { + headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + } + + LLEventStream replyPump(mAdapterName + "Reply", true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(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.get(), headers.get(), httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + LLCore::HttpStatus status = request->getStatus(); + LL_WARNS() << "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 + LLSD httpresults = LLSD::emptyMap(); + + httpHandler->writeStatusCodes(status, url, httpresults); + + LLSD errorres = LLSD::emptyMap(); + errorres["http_result"] = httpresults; + + return errorres; + } + + LLSD results = waitForEventOn(self, replyPump); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} } // end namespace LLCoreHttpUtil -- cgit v1.2.3 From 1c91c8a106a78f2087a3fb4312e428a0128283b4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Apr 2015 10:17:34 -0700 Subject: Adding weak pointer support. Event polling as a coroutine. (incomplete) Groundwork for canceling HttpCoroutineAdapter yields. --- indra/llmessage/llcorehttputil.cpp | 81 ++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 46 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 882fef66bc..d560ec8462 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -317,15 +317,18 @@ HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority) : mAdapterName(name), mPolicyId(policyId), - mPriority(priority) + mPriority(priority), + mYieldingHandle(LLCORE_HTTP_HANDLE_INVALID), + mWeakRequest() { } HttpCoroutineAdapter::~HttpCoroutineAdapter() { + } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -353,28 +356,17 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - LLCore::HttpStatus status = request->getStatus(); - LL_WARNS() << "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 - LLSD httpresults = LLSD::emptyMap(); - - httpHandler->writeStatusCodes(status, url, httpresults); - - LLSD errorres = LLSD::emptyMap(); - errorres["http_result"] = httpresults; - - return errorres; + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); } + mYieldingHandle = hhandle; LLSD results = waitForEventOn(self, replyPump); + mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, +LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -402,28 +394,17 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - LLCore::HttpStatus status = request->getStatus(); - LL_WARNS() << "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 - LLSD httpresults = LLSD::emptyMap(); - - httpHandler->writeStatusCodes(status, url, httpresults); - - LLSD errorres = LLSD::emptyMap(); - errorres["http_result"] = httpresults; - - return errorres; + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); } + mYieldingHandle = hhandle; LLSD results = waitForEventOn(self, replyPump); + mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t & request, +LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -450,26 +431,34 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - LLCore::HttpStatus status = request->getStatus(); - LL_WARNS() << "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 - LLSD httpresults = LLSD::emptyMap(); - - httpHandler->writeStatusCodes(status, url, httpresults); - - LLSD errorres = LLSD::emptyMap(); - errorres["http_result"] = httpresults; - - return errorres; + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); } + mYieldingHandle = hhandle; LLSD results = waitForEventOn(self, replyPump); + mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } +LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, + const std::string &url, LLCoreHttpUtil::HttpCoroHandler::ptr_t &httpHandler) +{ + LLCore::HttpStatus status = request->getStatus(); + LL_WARNS() << "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 + LLSD httpresults = LLSD::emptyMap(); + + httpHandler->writeStatusCodes(status, url, httpresults); + + LLSD errorres = LLSD::emptyMap(); + errorres["http_result"] = httpresults; + + return errorres; +} + } // end namespace LLCoreHttpUtil -- cgit v1.2.3 From 93382ee0c0c570e58b17af5f43f9738d773e8add Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Apr 2015 14:29:37 -0700 Subject: Moved some LLEventPolling internal classes to a named namespace Canceling outstanding polling transactions --- indra/llmessage/llcorehttputil.cpp | 104 +++++++++++++++++++++---------------- 1 file changed, 60 insertions(+), 44 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index d560ec8462..dd9cb2032a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -199,6 +199,12 @@ 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 + // cancel yet. Patience! + return; + } + if (!status) { result = LLSD::emptyMap(); @@ -290,6 +296,14 @@ void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::str } +LLCore::HttpStatus HttpCoroHandler::getStatusFromLLSD(const LLSD &httpResults) +{ + LLCore::HttpStatus::type_enum_t type = static_cast(httpResults["type"].asInteger()); + short code = static_cast(httpResults["status"].asInteger()); + + return LLCore::HttpStatus(type, code); +} + //======================================================================== HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request) : mHttpRequest(request) @@ -308,7 +322,10 @@ HttpRequestPumper::~HttpRequestPumper() bool HttpRequestPumper::pollRequest(const LLSD&) { - mHttpRequest->update(0L); + if (mHttpRequest->getStatus() != HttpStatus(HttpStatus::LLCORE, HE_OP_CANCELED)) + { + mHttpRequest->update(0L); + } return false; } @@ -319,29 +336,20 @@ HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, mPolicyId(policyId), mPriority(priority), mYieldingHandle(LLCORE_HTTP_HANDLE_INVALID), - mWeakRequest() + mWeakRequest(), + mWeakHandler() { } HttpCoroutineAdapter::~HttpCoroutineAdapter() { - + cancelYieldingOperation(); } LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - if (!options) - { - options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - } - - if (!headers) - { - headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - } - LLEventStream replyPump(mAdapterName, true); LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); @@ -356,12 +364,13 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - mYieldingHandle = hhandle; + saveState(hhandle, request, httpHandler); LLSD results = waitForEventOn(self, replyPump); - mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; + cleanState(); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } @@ -370,16 +379,6 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - if (!options) - { - options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - } - - if (!headers) - { - headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - } - LLEventStream replyPump(mAdapterName, true); LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); @@ -394,12 +393,12 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - mYieldingHandle = hhandle; + saveState(hhandle, request, httpHandler); LLSD results = waitForEventOn(self, replyPump); - mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; + cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } @@ -408,16 +407,6 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - if (!options) - { - options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); - } - - if (!headers) - { - headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); - } - LLEventStream replyPump(mAdapterName + "Reply", true); LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); @@ -431,18 +420,45 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { - return HttpCoroutineAdapter::buildImmediateErrorResult(request, url, httpHandler); + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - mYieldingHandle = hhandle; + saveState(hhandle, request, httpHandler); LLSD results = waitForEventOn(self, replyPump); - mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; + cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } +void HttpCoroutineAdapter::cancelYieldingOperation() +{ + LLCore::HttpRequest::ptr_t request = mWeakRequest.lock(); + HttpCoroHandler::ptr_t handler = mWeakHandler.lock(); + if ((request) && (handler) && (mYieldingHandle != LLCORE_HTTP_HANDLE_INVALID)) + { + cleanState(); + LL_INFOS() << "Canceling yielding request!" << LL_ENDL; + request->requestCancel(mYieldingHandle, handler.get()); + } +} + +void HttpCoroutineAdapter::saveState(LLCore::HttpHandle yieldingHandle, + LLCore::HttpRequest::ptr_t &request, HttpCoroHandler::ptr_t &handler) +{ + mWeakRequest = request; + mWeakHandler = handler; + mYieldingHandle = yieldingHandle; +} + +void HttpCoroutineAdapter::cleanState() +{ + mWeakRequest.reset(); + mWeakHandler.reset(); + mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; +} + LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, - const std::string &url, LLCoreHttpUtil::HttpCoroHandler::ptr_t &httpHandler) + const std::string &url) { LLCore::HttpStatus status = request->getStatus(); LL_WARNS() << "Error posting to " << url << " Status=" << status.getStatus() << @@ -452,7 +468,7 @@ LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest:: // to wait on LLSD httpresults = LLSD::emptyMap(); - httpHandler->writeStatusCodes(status, url, httpresults); + HttpCoroHandler::writeStatusCodes(status, url, httpresults); LLSD errorres = LLSD::emptyMap(); errorres["http_result"] = httpresults; -- cgit v1.2.3 From e28a5b6eadd4c38498665b44f1c7e197615139f2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 9 Apr 2015 16:46:41 -0700 Subject: Added LL_WARNS_IF to llerror.h If the coro is given something other than a map from the http then move the return into a body section. Changed windlight to use a coroutine and the new LLCore::Http libarary. Extra comments into Event Polling. --- indra/llmessage/llcorehttputil.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index dd9cb2032a..a32c4cad22 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -241,12 +241,19 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons } if (result.isUndefined()) - { - // 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 + // this method can return a map to the caller. + // *TODO: Should it always do this? + LLSD newResult = LLSD::emptyMap(); + newResult["content"] = result; + result = newResult; + } } buildStatusEntry(response, status, result); -- cgit v1.2.3 From d0c85b6dd964164b6d92103ad65b5cd859197de2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 10 Apr 2015 17:23:58 -0700 Subject: Adding support for DELETE, PATCH and COPY --- indra/llmessage/llcorehttputil.cpp | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index a32c4cad22..2d6cca214c 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -142,6 +142,46 @@ HttpHandle requestPutWithLLSD(HttpRequest::ptr_t & request, url, body, options.get(), headers.get(), handler); } +HttpHandle requestPatchWithLLSD(HttpRequest * request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * handler) +{ + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + BufferArray * ba = new BufferArray(); + BufferArrayStream bas(ba); + LLSDSerialize::toXML(body, bas); + + handle = request->requestPatch(policy_id, + priority, + url, + ba, + options, + headers, + handler); + ba->release(); + return handle; +} + +HttpHandle requestPatchWithLLSD(HttpRequest::ptr_t & request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) +{ + return requestPatchWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} + + std::string responseToString(LLCore::HttpResponse * response) { static const std::string empty("[Empty]"); -- cgit v1.2.3 From c4bcc83336c623b97e982443ce2f91d82d1a187d Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 16 Apr 2015 17:01:10 -0700 Subject: Facebook conversion. --- indra/llmessage/llcorehttputil.cpp | 91 +++++++++++++++++++++++++++++++------- 1 file changed, 76 insertions(+), 15 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 2d6cca214c..a3226ee2c3 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -291,7 +291,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons // this method can return a map to the caller. // *TODO: Should it always do this? LLSD newResult = LLSD::emptyMap(); - newResult["content"] = result; + newResult[HttpCoroutineAdapter::HTTP_RESULTS_CONTENT] = result; result = newResult; } } @@ -305,11 +305,6 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H LLSD httpresults = LLSD::emptyMap(); writeStatusCodes(status, response->getRequestURL(), httpresults); - // httpresults["success"] = static_cast(status); - // httpresults["type"] = static_cast(status.getType()); - // httpresults["status"] = static_cast(status.getStatus()); - // httpresults["message"] = static_cast(status.getMessage()); - // httpresults["url"] = static_cast(response->getRequestURL()); LLSD httpHeaders = LLSD::emptyMap(); LLCore::HttpHeaders * hdrs = response->getHeaders(); @@ -329,24 +324,24 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H } } - httpresults["headers"] = httpHeaders; - result["http_result"] = httpresults; + httpresults[HttpCoroutineAdapter::HTTP_RESULTS_HEADERS] = httpHeaders; + result[HttpCoroutineAdapter::HTTP_RESULTS] = httpresults; } void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::string &url, LLSD &result) { - result["success"] = static_cast(status); - result["type"] = static_cast(status.getType()); - result["status"] = static_cast(status.getStatus()); - result["message"] = static_cast(status.getMessage()); - result["url"] = static_cast(url); + result[HttpCoroutineAdapter::HTTP_RESULTS_SUCCESS] = static_cast(status); + result[HttpCoroutineAdapter::HTTP_RESULTS_TYPE] = static_cast(status.getType()); + result[HttpCoroutineAdapter::HTTP_RESULTS_STATUS] = static_cast(status.getStatus()); + result[HttpCoroutineAdapter::HTTP_RESULTS_MESSAGE] = static_cast(status.getMessage()); + result[HttpCoroutineAdapter::HTTP_RESULTS_URL] = static_cast(url); } LLCore::HttpStatus HttpCoroHandler::getStatusFromLLSD(const LLSD &httpResults) { - LLCore::HttpStatus::type_enum_t type = static_cast(httpResults["type"].asInteger()); - short code = static_cast(httpResults["status"].asInteger()); + LLCore::HttpStatus::type_enum_t type = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_TYPE].asInteger()); + short code = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_STATUS].asInteger()); return LLCore::HttpStatus(type, code); } @@ -377,6 +372,16 @@ bool HttpRequestPumper::pollRequest(const LLSD&) } //======================================================================== +const std::string HttpCoroutineAdapter::HTTP_RESULTS("http_result"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_SUCCESS("success"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_TYPE("type"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_STATUS("status"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_MESSAGE("message"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_URL("url"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_HEADERS("headers"); +const std::string HttpCoroutineAdapter::HTTP_RESULTS_CONTENT("content"); + + HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority) : mAdapterName(name), @@ -422,6 +427,34 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques return results; } +LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, 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); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(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.get(), headers.get(), httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); + } + + saveState(hhandle, request, httpHandler); + LLSD results = waitForEventOn(self, replyPump); + cleanState(); + + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} + LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) @@ -477,6 +510,34 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest return results; } +LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName + "Reply", true); + LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = + LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + + //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; + LLCoreHttpUtil::HttpRequestPumper pumper(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.get(), headers.get(), httpHandler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); + } + + saveState(hhandle, request, httpHandler); + LLSD results = waitForEventOn(self, replyPump); + cleanState(); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} + + void HttpCoroutineAdapter::cancelYieldingOperation() { LLCore::HttpRequest::ptr_t request = mWeakRequest.lock(); -- cgit v1.2.3 From cd55655592b7518451d78b1ef229bce3316af420 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Apr 2015 13:12:09 -0700 Subject: Crash logger changes to LLCore::Http --- indra/llmessage/llcorehttputil.cpp | 39 +------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index a3226ee2c3..1f9d4d15cd 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -90,18 +90,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, return handle; } -HttpHandle requestPostWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) -{ - return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); -} + HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, @@ -129,19 +118,6 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, return handle; } -HttpHandle requestPutWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) -{ - return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); -} - HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, @@ -168,19 +144,6 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, return handle; } -HttpHandle requestPatchWithLLSD(HttpRequest::ptr_t & request, - HttpRequest::policy_t policy_id, - HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, - HttpHandler * handler) -{ - return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); -} - std::string responseToString(LLCore::HttpResponse * response) { -- cgit v1.2.3 From 3e004ce66e1fa07421c138a20eb0dba61c5b26b3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 11 May 2015 16:52:02 -0700 Subject: Updated feature manager downloader to coroutine. Added "raw" coroutine handler (returns raw result as LLSD::Binary) and split out the guts of the get, put, etc methods. Moved getStatusFromLLSD from HttpCoroHandler into HttpCorutineAdapter --- indra/llmessage/llcorehttputil.cpp | 303 +++++++++++++++++++++++++++---------- 1 file changed, 226 insertions(+), 77 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 1f9d4d15cd..a79bb62bb8 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -28,7 +28,8 @@ #include "linden_common.h" #include - +#include +#include #include "llcorehttputil.h" #include "llhttpconstants.h" #include "llsdserialize.h" @@ -38,9 +39,25 @@ using namespace LLCore; namespace LLCoreHttpUtil { +//========================================================================= +/// The HttpRequestPumper is a utility class. When constructed it will poll the +/// supplied HttpRequest once per frame until it is destroyed. +/// +class HttpRequestPumper +{ +public: + HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request); + ~HttpRequestPumper(); +private: + bool pollRequest(const LLSD&); + LLTempBoundListener mBoundListener; + LLCore::HttpRequest::ptr_t mHttpRequest; +}; + +//========================================================================= // *TODO: Currently converts only from XML content. A mode // to convert using fromBinary() might be useful as well. Mesh // headers could use it. @@ -91,7 +108,6 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, } - HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, @@ -191,6 +207,7 @@ std::string responseToString(LLCore::HttpResponse * response) } //======================================================================== + HttpCoroHandler::HttpCoroHandler(LLEventStream &reply) : mReplyPump(reply) { @@ -221,42 +238,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons } else { - const bool emit_parse_errors = false; - - bool parsed = !((response->getBodySize() == 0) || - !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, result)); - - if (!parsed) - { - // 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."); - } - } - - if (result.isUndefined()) - { // 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 - // this method can return a map to the caller. - // *TODO: Should it always do this? - LLSD newResult = LLSD::emptyMap(); - newResult[HttpCoroutineAdapter::HTTP_RESULTS_CONTENT] = result; - result = newResult; - } + result = this->handleSuccess(response, status); } buildStatusEntry(response, status, result); @@ -301,12 +283,126 @@ void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::str } -LLCore::HttpStatus HttpCoroHandler::getStatusFromLLSD(const LLSD &httpResults) +//========================================================================= +/// 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. +/// +/// 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 +/// +- ["success"] - Success of failure of the HTTP call and LLSD parsing. +/// +- ["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 { - LLCore::HttpStatus::type_enum_t type = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_TYPE].asInteger()); - short code = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_STATUS].asInteger()); +public: + HttpCoroLLSDHandler(LLEventStream &reply); - return LLCore::HttpStatus(type, code); +protected: + virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); +}; + +//------------------------------------------------------------------------- +HttpCoroLLSDHandler::HttpCoroLLSDHandler(LLEventStream &reply): + HttpCoroHandler(reply) +{ +} + + +LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status) +{ + LLSD result; + + const bool emit_parse_errors = false; + + bool parsed = !((response->getBodySize() == 0) || + !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, result)); + + if (!parsed) + { + // 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."); + } + } + + if (result.isUndefined()) + { // 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 + // this method can return a map to the caller. + // *TODO: Should it always do this? + LLSD newResult = LLSD::emptyMap(); + newResult[HttpCoroutineAdapter::HTTP_RESULTS_CONTENT] = result; + result = newResult; + } + + return result; +} + +//======================================================================== +/// 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: + HttpCoroRawHandler(LLEventStream &reply); + + virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); +}; + +//------------------------------------------------------------------------- +HttpCoroRawHandler::HttpCoroRawHandler(LLEventStream &reply): + HttpCoroHandler(reply) +{ +} + +LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status) +{ + LLSD result = LLSD::emptyMap(); + + BufferArray * body(response->getBody()); + if (!body || !body->size()) + { + return result; + } + + size_t size = body->size(); + + LLCore::BufferArrayStream bas(body); + + // 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 reference so that we can modify it. + result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = LLSD::Binary(); + LLSD::Binary &data = const_cast( result[HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary() ); + + data.reserve(size); + bas >> std::noskipws; + data.assign(std::istream_iterator(bas), std::istream_iterator()); + + return result; } //======================================================================== @@ -343,7 +439,7 @@ const std::string HttpCoroutineAdapter::HTTP_RESULTS_MESSAGE("message"); const std::string HttpCoroutineAdapter::HTTP_RESULTS_URL("url"); const std::string HttpCoroutineAdapter::HTTP_RESULTS_HEADERS("headers"); const std::string HttpCoroutineAdapter::HTTP_RESULTS_CONTENT("content"); - +const std::string HttpCoroutineAdapter::HTTP_RESULTS_RAW("raw"); HttpCoroutineAdapter::HttpCoroutineAdapter(const std::string &name, LLCore::HttpRequest::policy_t policyId, LLCore::HttpRequest::priority_t priority) : @@ -366,27 +462,33 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + return postAndYield_(self, request, url, body, options, headers, httpHandler); +} + +LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, 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) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(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 = requestPostWithLLSD(request, mPolicyId, mPriority, url, body, options, headers, - httpHandler.get()); + handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } @@ -395,23 +497,30 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName, true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + + return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); +} +LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, 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) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(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.get(), headers.get(), httpHandler.get()); + LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(), + options.get(), headers.get(), handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -422,25 +531,32 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - LLEventStream replyPump(mAdapterName, true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + LLEventStream replyPump(mAdapterName + "Reply", true); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + return putAndYield_(self, request, url, body, options, headers, httpHandler); +} + +LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, 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) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(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 = requestPutWithLLSD(request, mPolicyId, mPriority, url, body, options, headers, - httpHandler.get()); + handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -451,50 +567,74 @@ LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + + return getAndYield_(self, request, url, options, headers, httpHandler); +} + +LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, 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)); + + return getAndYield_(self, request, url, options, headers, httpHandler); +} +LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(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.get(), headers.get(), httpHandler.get()); + LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority, + url, options.get(), headers.get(), handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } + LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { LLEventStream replyPump(mAdapterName + "Reply", true); - LLCoreHttpUtil::HttpCoroHandler::ptr_t httpHandler = - LLCoreHttpUtil::HttpCoroHandler::ptr_t(new LLCoreHttpUtil::HttpCoroHandler(replyPump)); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + + return deleteAndYield_(self, request, url, options, headers, httpHandler); +} +LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, + const std::string & url, LLCore::HttpOptions::ptr_t &options, + LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) +{ //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; - LLCoreHttpUtil::HttpRequestPumper pumper(request); + HttpRequestPumper pumper(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.get(), headers.get(), httpHandler.get()); + url, options.get(), headers.get(), handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); } - saveState(hhandle, request, httpHandler); - LLSD results = waitForEventOn(self, replyPump); + saveState(hhandle, request, handler); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -547,5 +687,14 @@ LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest:: return errorres; } +LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResults) +{ + LLCore::HttpStatus::type_enum_t type = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_TYPE].asInteger()); + short code = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_STATUS].asInteger()); + + return LLCore::HttpStatus(type, code); +} + + } // end namespace LLCoreHttpUtil -- cgit v1.2.3 From 723834737dc8bdb608f73c5d7fe5bdebfdaa59e5 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 12 May 2015 14:32:43 -0700 Subject: Added trivial case GET and POST to the CoreHTTP Utils converted llfloaterregioninfo to use coroutine's and new LLCore::HTTP --- indra/llmessage/llcorehttputil.cpp | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index a79bb62bb8..2ef9f59e2f 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -668,6 +668,7 @@ void HttpCoroutineAdapter::cleanState() mYieldingHandle = LLCORE_HTTP_HANDLE_INVALID; } +/*static*/ LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, const std::string &url) { @@ -687,6 +688,7 @@ LLSD HttpCoroutineAdapter::buildImmediateErrorResult(const LLCore::HttpRequest:: return errorres; } +/*static*/ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResults) { LLCore::HttpStatus::type_enum_t type = static_cast(httpResults[HttpCoroutineAdapter::HTTP_RESULTS_TYPE].asInteger()); @@ -695,6 +697,77 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul return LLCore::HttpStatus(type, code); } +/*static*/ +void HttpCoroutineAdapter::genericHttpGet(const std::string &url, const std::string &success, const std::string &failure) +{ + LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", + boost::bind(&HttpCoroutineAdapter::genericGetCoro, _1, url, success, failure)); +} + +/*static*/ +void HttpCoroutineAdapter::genericGetCoro(LLCoros::self& self, std::string &url, std::string success, std::string failure) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; + + LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (status) + { + LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Success for " << url << std::endl << + "Message: '" << success << "'" << LL_ENDL; + } + else + { + LL_WARNS("HttpCoroutineAdapter", "genericGetCoro") << "Failure for " << url << std::endl << + "Message: '" << failure << "'" << std::endl << + "Status: " << status.toTerseString() << ": " << status.getMessage() << LL_ENDL; + } +} + +/*static*/ +void HttpCoroutineAdapter::genericHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure) +{ + LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", + boost::bind(&HttpCoroutineAdapter::genericPostCoro, _1, url, postData, success, failure)); +} + +/*static*/ +void HttpCoroutineAdapter::genericPostCoro(LLCoros::self& self, std::string &url, LLSD postData, std::string success, std::string failure) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + + LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; + + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (status) + { + LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Success for " << url << std::endl << + "Message: '" << success << "'" << LL_ENDL; + } + else + { + LL_WARNS("HttpCoroutineAdapter", "genericPostCoro") << "Failure for " << url << std::endl << + "Message: '" << failure << "'" << std::endl << + "Status: " << status.toTerseString() << ": " << status.getMessage() << LL_ENDL; + } +} + + } // end namespace LLCoreHttpUtil -- cgit v1.2.3 From 9ec050a0673c28b25eeb28ae7926ff1070cbb4c3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 14 May 2015 10:33:46 -0700 Subject: Make generic callback version of trivial GET/PUT methods. Make message use these methods. --- indra/llmessage/llcorehttputil.cpp | 75 +++++++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 18 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 2ef9f59e2f..521131a986 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -39,6 +39,16 @@ using namespace LLCore; namespace LLCoreHttpUtil { +void logMessageSuccess(std::string logAuth, std::string url, std::string message) +{ + LL_INFOS() << logAuth << " Success '" << message << "' for " << url << LL_ENDL; +} + +void logMessageFail(std::string logAuth, std::string url, std::string message) +{ + LL_WARNS() << logAuth << " Failure '" << message << "' for " << url << LL_ENDL; +} + //========================================================================= /// The HttpRequestPumper is a utility class. When constructed it will poll the /// supplied HttpRequest once per frame until it is destroyed. @@ -698,14 +708,24 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul } /*static*/ -void HttpCoroutineAdapter::genericHttpGet(const std::string &url, const std::string &success, const std::string &failure) +void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::genericGetCoro, _1, url, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, success, failure)); } /*static*/ -void HttpCoroutineAdapter::genericGetCoro(LLCoros::self& self, std::string &url, std::string success, std::string failure) +void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::string &success, const std::string &failure) +{ + completionCallback_t cbSuccess = (success.empty()) ? NULL : + static_cast(boost::bind(&logMessageSuccess, "HttpCoroutineAdapter", url, success)); + completionCallback_t cbFailure = (failure.empty()) ? NULL : + static_cast(boost::bind(&logMessageFail, "HttpCoroutineAdapter", url, failure)); + callbackHttpGet(url, cbSuccess, cbFailure); +} + +/*static*/ +void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string &url, completionCallback_t success, completionCallback_t failure) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -719,28 +739,43 @@ void HttpCoroutineAdapter::genericGetCoro(LLCoros::self& self, std::string &url, LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if (status) + if (!status) { - LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Success for " << url << std::endl << - "Message: '" << success << "'" << LL_ENDL; + if (failure) + { + failure(httpResults); + } } else { - LL_WARNS("HttpCoroutineAdapter", "genericGetCoro") << "Failure for " << url << std::endl << - "Message: '" << failure << "'" << std::endl << - "Status: " << status.toTerseString() << ": " << status.getMessage() << LL_ENDL; + if (success) + { // remove the added http_result entry from the results before calling the callback. + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + success(result); + } } } /*static*/ -void HttpCoroutineAdapter::genericHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure) +void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::genericPostCoro, _1, url, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, postData, success, failure)); } /*static*/ -void HttpCoroutineAdapter::genericPostCoro(LLCoros::self& self, std::string &url, LLSD postData, std::string success, std::string failure) +void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure) +{ + completionCallback_t cbSuccess = (success.empty()) ? NULL : + static_cast(boost::bind(&logMessageSuccess, "HttpCoroutineAdapter", url, success)); + completionCallback_t cbFailure = (failure.empty()) ? NULL : + static_cast(boost::bind(&logMessageFail, "HttpCoroutineAdapter", url, failure)); + + callbackHttpPost(url, postData, cbSuccess, cbFailure); +} + +/*static*/ +void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string &url, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -754,16 +789,20 @@ void HttpCoroutineAdapter::genericPostCoro(LLCoros::self& self, std::string &url LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - if (status) + if (!status) { - LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Success for " << url << std::endl << - "Message: '" << success << "'" << LL_ENDL; + if (failure) + { + failure(httpResults); + } } else { - LL_WARNS("HttpCoroutineAdapter", "genericPostCoro") << "Failure for " << url << std::endl << - "Message: '" << failure << "'" << std::endl << - "Status: " << status.toTerseString() << ": " << status.getMessage() << LL_ENDL; + if (success) + { // remove the added http_result entry from the results before calling the callback. + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + success(result); + } } } -- cgit v1.2.3 From 21701459ee26e821931d6bebf975df59b35d8fd9 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 14 May 2015 15:47:36 -0700 Subject: Converted the Server release notes URL, classified and click tracker, Avatar hover height Pass the http_results on successfull call back style completion as well. --- indra/llmessage/llcorehttputil.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 521131a986..8da62ca839 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -298,6 +298,9 @@ void HttpCoroHandler::writeStatusCodes(LLCore::HttpStatus status, const std::str /// 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 @@ -405,6 +408,8 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: // 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 reference so that we can modify it. + // *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( result[HttpCoroutineAdapter::HTTP_RESULTS_RAW].asBinary() ); @@ -731,10 +736,13 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string &url, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url); + LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -749,8 +757,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string &url, else { if (success) - { // remove the added http_result entry from the results before calling the callback. - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + { success(result); } } @@ -781,16 +788,20 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string &url LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + httpOpts->setWantHeaders(true); LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData); + LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); if (!status) { + // If a failure routine is provided do it. if (failure) { failure(httpResults); @@ -798,9 +809,9 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string &url } else { + // If a success routine is provided do it. if (success) - { // remove the added http_result entry from the results before calling the callback. - result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + { success(result); } } -- cgit v1.2.3 From f26fb73dd8a7794df580e6a58744d76dde293569 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 15 May 2015 12:51:18 -0700 Subject: Address Nat's concerns about the const_cast<> and modification of a binary object wrapped in an LLSD object. --- indra/llmessage/llcorehttputil.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 8da62ca839..f8f5866355 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -405,6 +405,22 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: LLCore::BufferArrayStream bas(body); +#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; + data.assign(std::istream_iterator(bas), std::istream_iterator()); + + result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = data; + +#else + // 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 reference so that we can modify it. @@ -416,6 +432,7 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: data.reserve(size); bas >> std::noskipws; data.assign(std::istream_iterator(bas), std::istream_iterator()); +#endif return result; } -- cgit v1.2.3 From a4741cecb2112f418c1d98ca63a261e707a856c3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 18 May 2015 16:18:07 -0700 Subject: Changed Avatar picker to use coroutine for find. Fixed a stray reference (&) on URL that had crept into some coroutine definitions. --- indra/llmessage/llcorehttputil.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index f8f5866355..cf34029dfe 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -747,7 +747,7 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string &url, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, completionCallback_t success, completionCallback_t failure) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t @@ -799,7 +799,7 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string &url, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t -- cgit v1.2.3 From c437a9c4ec865c38366c8057010d24311888ecb1 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 20 May 2015 17:37:27 -0700 Subject: Webprofile converted to coroutine. Added JSON->LLSD converter Added corohandler for JSON data --- indra/llmessage/llcorehttputil.cpp | 82 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index cf34029dfe..05d2e84f88 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -32,7 +32,10 @@ #include #include "llcorehttputil.h" #include "llhttpconstants.h" +#include "llsd.h" +#include "llsdjson.h" #include "llsdserialize.h" +#include "reader.h" using namespace LLCore; @@ -252,6 +255,23 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons } buildStatusEntry(response, status, result); + +#if 0 + // commenting out, but keeping since this can be useful for debugging + if (!status) + { + LLSD &httpStatus = result[HttpCoroutineAdapter::HTTP_RESULTS]; + + LLCore::BufferArray *body = response->getBody(); + LLCore::BufferArrayStream bas(body); + LLSD::Binary bodyData; + bodyData.reserve(response->getBodySize()); + bas >> std::noskipws; + bodyData.assign(std::istream_iterator(bas), std::istream_iterator()); + httpStatus["error_body"] = bodyData; + } +#endif + mReplyPump.post(result); } @@ -437,6 +457,58 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: return result; } +//======================================================================== +/// 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: + HttpCoroJSONHandler(LLEventStream &reply); + + virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); +}; + +//------------------------------------------------------------------------- +HttpCoroJSONHandler::HttpCoroJSONHandler(LLEventStream &reply) : + HttpCoroHandler(reply) +{ +} + +LLSD HttpCoroJSONHandler::handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status) +{ + LLSD result = LLSD::emptyMap(); + + BufferArray * body(response->getBody()); + if (!body || !body->size()) + { + return result; + } + + LLCore::BufferArrayStream bas(body); + Json::Value jsonRoot; + + try + { + bas >> jsonRoot; + } + catch (std::runtime_error e) + { // deserialization failed. Record the reason and pass back an empty map for markup. + status = LLCore::HttpStatus(499, std::string(e.what())); + return result; + } + + // Convert the JSON structure to LLSD + result = LlsdFromJson(jsonRoot); + + return result; +} + + //======================================================================== HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request) : mHttpRequest(request) @@ -614,6 +686,16 @@ LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, LLCore::HttpRequ return getAndYield_(self, request, url, options, headers, httpHandler); } +LLSD HttpCoroutineAdapter::getJsonAndYield(LLCoros::self & self, 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)); + + return getAndYield_(self, request, url, options, headers, httpHandler); +} + + LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, -- cgit v1.2.3 From f7fa3b5f564cdba323e7ba19928e497d252892e0 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 22 May 2015 10:59:43 -0700 Subject: Floater IM Session to trivial coroutine. Changed debugging output from core utitl to string. --- indra/llmessage/llcorehttputil.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 05d2e84f88..001df9e385 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -264,11 +264,13 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons LLCore::BufferArray *body = response->getBody(); LLCore::BufferArrayStream bas(body); - LLSD::Binary bodyData; + LLSD::String bodyData; bodyData.reserve(response->getBodySize()); bas >> std::noskipws; bodyData.assign(std::istream_iterator(bas), std::istream_iterator()); - httpStatus["error_body"] = bodyData; + httpStatus["error_body"] = LLSD(bodyData); + + LL_WARNS() << "Returned body=" << std::endl << httpStatus["error_body"].asString() << LL_ENDL; } #endif -- cgit v1.2.3 From 83543e556cba8753077c9f004bb0dc71b4509007 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 27 May 2015 17:15:01 -0700 Subject: Memory leak (extra ref) in webprofile Viewer media routines to coroutine. Post with raw respons in llcorehttputil LLCore::Http added headers only option (applies only on get) --- indra/llmessage/llcorehttputil.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 001df9e385..c4a7e9040a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -256,7 +256,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons buildStatusEntry(response, status, result); -#if 0 +#if 1 // commenting out, but keeping since this can be useful for debugging if (!status) { @@ -608,6 +608,16 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpReques return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); } +LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, 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)); + + return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); +} + LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, -- cgit v1.2.3 From d0d58c41b48f8a2a0e18610b577059ee8419be5c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 4 Jun 2015 17:36:24 -0700 Subject: Default headers added. Group manager finished conversion. Outfit folders coverted. --- indra/llmessage/llcorehttputil.cpp | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index c4a7e9040a..1fd7e7be2e 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -37,6 +37,8 @@ #include "llsdserialize.h" #include "reader.h" +#include "message.h" // for getting the port + using namespace LLCore; @@ -243,11 +245,10 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons result = LLSD::emptyMap(); LL_WARNS() << "\n--------------------------------------------------------------------------\n" - << " Error[" << status.toULong() << "] cannot access url '" << response->getRequestURL() + << " Error[" << status.getType() << "] cannot access url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; - } else { @@ -578,8 +579,10 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; 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 = requestPostWithLLSD(request, @@ -623,8 +626,10 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; 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->requestPost(mPolicyId, mPriority, url, rawbody.get(), @@ -658,8 +663,10 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpReques LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; 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 = requestPutWithLLSD(request, @@ -713,8 +720,9 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; 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->requestGet(mPolicyId, mPriority, @@ -747,8 +755,9 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { - //LL_INFOS() << "Requesting transaction " << transactionId << LL_ENDL; 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->requestDelete(mPolicyId, mPriority, @@ -766,6 +775,21 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq return results; } +void HttpCoroutineAdapter::checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers) +{ + if (!headers) + headers.reset(new LLCore::HttpHeaders); + if (!headers->find(HTTP_OUT_HEADER_ACCEPT)) + { + headers->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML); + } + + if (!headers->find("X-SecondLife-UDP-Listen-Port") && gMessageSystem) + { + headers->append("X-SecondLife-UDP-Listen-Port", llformat("%d", gMessageSystem->mPort)); + } +} + void HttpCoroutineAdapter::cancelYieldingOperation() { -- cgit v1.2.3 From cf4fec954ca46a139465144ccc3888b8fc7d41da Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 8 Jun 2015 17:29:01 -0700 Subject: Added a way to pass a policy Id to the coroadapter. Changed language, appearance, and maturity to conform to use the adapter rather than the SDHandler --- indra/llmessage/llcorehttputil.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 1fd7e7be2e..9ccebabab4 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -848,10 +848,10 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul } /*static*/ -void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, policyId, success, failure)); } /*static*/ @@ -865,13 +865,12 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", httpPolicy)); + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); @@ -899,10 +898,10 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, } /*static*/ -void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, const LLSD &postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, LLCore::HttpRequest::policy_t policyId, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, policyId, postData, success, failure)); } /*static*/ @@ -917,13 +916,12 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) { - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t - httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy)); + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); httpOpts->setWantHeaders(true); -- cgit v1.2.3 From 08ef748cba55d5d950b224710c8592e94fcce5c7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 25 Jun 2015 15:47:56 -0700 Subject: Added file upload interface to core HTTP utils. --- indra/llmessage/llcorehttputil.cpp | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 9ccebabab4..68c55eaf54 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -36,6 +36,7 @@ #include "llsdjson.h" #include "llsdserialize.h" #include "reader.h" +#include "llvfile.h" #include "message.h" // for getting the port @@ -621,6 +622,61 @@ LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, LLCore::HttpReq return postAndYield_(self, 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(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, std::string fileName, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray, false); + + // scoping for our streams so that they go away when we no longer need them. + { + LLCore::BufferArrayStream outs(fileData.get()); + llifstream ins(fileName.c_str(), std::iostream::binary | std::iostream::out); + + if (ins.is_open()) + { + + ins.seekg(0, std::ios::beg); + ins >> std::noskipws; + + std::copy(std::istream_iterator(ins), std::istream_iterator(), + std::ostream_iterator(outs)); + + ins.close(); + } + } + + return postAndYield(self, 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(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, + const std::string & url, LLUUID assetId, LLAssetType::EType assetType, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray, false); + + // scoping for our streams so that they go away when we no longer need them. + { + LLCore::BufferArrayStream outs(fileData.get()); + LLVFile vfile(gVFS, assetId, assetType, LLVFile::READ); + + S32 fileSize = vfile.getSize(); + U8* fileBuffer; + fileBuffer = new U8[fileSize]; + vfile.read(fileBuffer, fileSize); + + outs.write((char*)fileBuffer, fileSize); + delete[] fileBuffer; + } + + return postAndYield(self, request, url, fileData, options, headers); +} + + LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, -- cgit v1.2.3 From 80d17b2dd9cdd7a9445480fdb0e12774396751eb Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 29 Jun 2015 17:19:51 -0400 Subject: MAINT-4952: Use IntrusivePtr for BufferArray,HttpHeaders,HttpOptions. Specifically, change the ptr_t typedefs for these LLCore classes to use IntrusivePtr rather than directly using boost::intrusive_ptr. This allows us to use a simple ptr_t(raw ptr) constructor rather than having to remember to code ptr_t(raw ptr, false) everywhere. In fact, the latter form is now invalid: remove the now-extraneous 'false' constructor parameters. --- indra/llmessage/llcorehttputil.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 68c55eaf54..4ec01aa405 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -628,7 +628,7 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray, false); + LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray); // scoping for our streams so that they go away when we no longer need them. { @@ -657,7 +657,7 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe const std::string & url, LLUUID assetId, LLAssetType::EType assetType, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { - LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray, false); + LLCore::BufferArray::ptr_t fileData(new LLCore::BufferArray); // scoping for our streams so that they go away when we no longer need them. { @@ -926,7 +926,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); @@ -977,7 +977,7 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions, false); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); -- cgit v1.2.3 From b262ded7e0cf21314524bf702b0e4fe28a3c3060 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 1 Jul 2015 18:33:29 -0400 Subject: MAINT-5351: Remove 'self' parameter from coroutine functions. lleventcoro_test.cpp runs clean (as modified for new API), and all the rest builds clean, but the resulting viewer is as yet untested. --- indra/llmessage/llcorehttputil.cpp | 72 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 4ec01aa405..ac1c2f8e58 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -565,17 +565,17 @@ HttpCoroutineAdapter::~HttpCoroutineAdapter() cancelYieldingOperation(); } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(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)); - return postAndYield_(self, request, url, body, options, headers, httpHandler); + return postAndYield_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(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) @@ -596,35 +596,35 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(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)); - return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); + return postAndYield_(request, url, rawbody, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postRawAndYield(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)); - return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); + return postAndYield_(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(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -648,12 +648,12 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe } } - return postAndYield(self, request, url, fileData, options, headers); + return postAndYield(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(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndYield(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 +673,11 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe delete[] fileBuffer; } - return postAndYield(self, request, url, fileData, options, headers); + return postAndYield(request, url, fileData, options, headers); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(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) @@ -697,24 +697,24 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::putAndYield(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)); - return putAndYield_(self, request, url, body, options, headers, httpHandler); + return putAndYield_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::putAndYield_(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) @@ -735,43 +735,43 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpReques } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getAndYield(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)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getRawAndYield(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)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getJsonAndYield(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)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -790,24 +790,24 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::deleteAndYield(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)); - return deleteAndYield_(self, request, url, options, headers, httpHandler); + return deleteAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -907,7 +907,7 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, policyId, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, url, policyId, success, failure)); } /*static*/ @@ -921,7 +921,7 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); @@ -932,7 +932,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -957,7 +957,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, LLCore::HttpRequest::policy_t policyId, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, policyId, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, url, policyId, postData, success, failure)); } /*static*/ @@ -972,7 +972,7 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); @@ -983,7 +983,7 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From f90023fc0b3b61fd346a2b56e30e5f3c35814192 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 2 Jul 2015 17:00:32 -0400 Subject: MAINT-5357: Introduce and populate llcoro:: namespace. To date, the coroutine helper functions in lleventcoro.h have been in the global namespace. Migrate them into llcoro namespace, and fix references. Specifically, LLVoidListener => llcoro::VoidListener, and voidlistener(), postAndWait(), both waitForEventOn(), postAndWait2(), errorException() and errorLog() have been moved into llcoro. Also migrate new LLCoros::get_self() and Suspending to llcoro:: namespace. While at it, I realized that -- having converted several lleventcoro.h functions from templates (for arbitrary 'self' parameter type) to ordinary functions, having moved them from lleventcoro.h to lleventcoro.cpp, we can now migrate their helpers from lleventcoro.h to lleventcoro.cpp as well. This eliminates the need for the LLEventDetail namespace; the relevant helpers are now in an anonymous namespace in the .cpp file: listenerNameForCoro(), storeToLLSDPath(), WaitForEventOnHelper and wfeoh(). --- indra/llmessage/llcorehttputil.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index ac1c2f8e58..cd3c527241 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -596,7 +596,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); return results; @@ -697,7 +697,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -735,7 +735,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -790,7 +790,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; -- cgit v1.2.3 From 4c1d47d4ae231c1141c6ecf707c033563c99382a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Jul 2015 19:31:34 +0100 Subject: Backed out selfless merge --- indra/llmessage/llcorehttputil.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index cd3c527241..ac1c2f8e58 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -596,7 +596,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); return results; @@ -697,7 +697,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -735,7 +735,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -790,7 +790,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; -- cgit v1.2.3 From 247eb0c9c3418c10be8f2a0e3c8116758efa702f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 7 Jul 2015 19:41:27 +0100 Subject: Backout selfles merge 738255dbbfd679d9e615baab3398e5e345bbb3c5 --- indra/llmessage/llcorehttputil.cpp | 72 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index ac1c2f8e58..4ec01aa405 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -565,17 +565,17 @@ HttpCoroutineAdapter::~HttpCoroutineAdapter() cancelYieldingOperation(); } -LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, 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)); - return postAndYield_(request, url, body, options, headers, httpHandler); + return postAndYield_(self, request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, 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) @@ -596,35 +596,35 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, 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)); - return postAndYield_(request, url, rawbody, options, headers, httpHandler); + return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postRawAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, 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)); - return postAndYield_(request, url, rawbody, options, headers, httpHandler); + return postAndYield_(self, 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::postFileAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -648,12 +648,12 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, } } - return postAndYield(request, url, fileData, options, headers); + return postAndYield(self, 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::postFileAndYield(LLCoros::self & self, 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 +673,11 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, delete[] fileBuffer; } - return postAndYield(request, url, fileData, options, headers); + return postAndYield(self, request, url, fileData, options, headers); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, 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) @@ -697,24 +697,24 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::putAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, 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)); - return putAndYield_(request, url, body, options, headers, httpHandler); + return putAndYield_(self, request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, 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) @@ -735,43 +735,43 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::getAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, 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)); - return getAndYield_(request, url, options, headers, httpHandler); + return getAndYield_(self, request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getRawAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, 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)); - return getAndYield_(request, url, options, headers, httpHandler); + return getAndYield_(self, request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getJsonAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getJsonAndYield(LLCoros::self & self, 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)); - return getAndYield_(request, url, options, headers, httpHandler); + return getAndYield_(self, request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -790,24 +790,24 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::deleteAndYield(LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, 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)); - return deleteAndYield_(request, url, options, headers, httpHandler); + return deleteAndYield_(self, request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = waitForEventOn(self, handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -907,7 +907,7 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::trivialGetCoro, url, policyId, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, policyId, success, failure)); } /*static*/ @@ -921,7 +921,7 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); @@ -932,7 +932,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->getAndYield(self, httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -957,7 +957,7 @@ void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest:: void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, LLCore::HttpRequest::policy_t policyId, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::trivialPostCoro, url, policyId, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, policyId, postData, success, failure)); } /*static*/ @@ -972,7 +972,7 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); @@ -983,7 +983,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->postAndYield(self, httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From 1138c57f9a8553903199e727912d7f1b092697e4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 10:01:27 -0700 Subject: Convert LLCore::HttpHeaders to use shared_ptr<> rather than an intrusive_ptr<> for refrence counting. --- indra/llmessage/llcorehttputil.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 4ec01aa405..e3588b74ee 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -103,7 +103,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, const std::string & url, const LLSD & body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -130,7 +130,7 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, const std::string & url, const LLSD & body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -156,7 +156,7 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, const std::string & url, const LLSD & body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -286,7 +286,7 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H writeStatusCodes(status, response->getRequestURL(), httpresults); LLSD httpHeaders = LLSD::emptyMap(); - LLCore::HttpHeaders * hdrs = response->getHeaders(); + LLCore::HttpHeaders::ptr_t hdrs = response->getHeaders(); if (hdrs) { @@ -689,7 +689,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque // 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.get(), headers.get(), handler.get()); + options.get(), headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -782,7 +782,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques // 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.get(), headers.get(), handler.get()); + url, options.get(), headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -817,7 +817,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq // 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.get(), headers.get(), handler.get()); + url, options.get(), headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { -- cgit v1.2.3 From fe5567639d7d4b6f13f66da0a1fb4bf2af295283 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 12:09:36 -0700 Subject: Change HttpOptions::ptr_t to be shared_ptr<> rather than intrusive. --- indra/llmessage/llcorehttputil.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index e3588b74ee..24f5d77ee1 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,7 +102,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions * options, + HttpOptions::ptr_t &options, HttpHeaders::ptr_t &headers, HttpHandler * handler) { @@ -129,7 +129,7 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions * options, + HttpOptions::ptr_t &options, HttpHeaders::ptr_t &headers, HttpHandler * handler) { @@ -155,7 +155,7 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions * options, + HttpOptions::ptr_t &options, HttpHeaders::ptr_t &headers, HttpHandler * handler) { @@ -689,7 +689,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque // 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.get(), headers, handler.get()); + options, headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -782,7 +782,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques // 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.get(), headers, handler.get()); + url, options, headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -817,7 +817,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq // 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.get(), headers, handler.get()); + url, options, headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { -- cgit v1.2.3 From ef3d1d642eb384fff853e227b92e20d66dbb8db7 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 13:41:07 -0700 Subject: Replace ref parameter with value --- indra/llmessage/llcorehttputil.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 24f5d77ee1..5b5929383a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,8 +102,8 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t &options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t options, + HttpHeaders::ptr_t headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -129,8 +129,8 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t &options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t options, + HttpHeaders::ptr_t headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -155,8 +155,8 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t &options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t options, + HttpHeaders::ptr_t headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); -- cgit v1.2.3 From 75b12d79e1aeeef297182e4419df7022ede485f3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 14:49:08 -0700 Subject: Enforcing constness of refs --- indra/llmessage/llcorehttputil.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 5b5929383a..a2004db30a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,8 +102,8 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t options, - HttpHeaders::ptr_t headers, + const HttpOptions::ptr_t &options, + const HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -129,8 +129,8 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t options, - HttpHeaders::ptr_t headers, + const HttpOptions::ptr_t &options, + const HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -155,8 +155,8 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t options, - HttpHeaders::ptr_t headers, + const HttpOptions::ptr_t &options, + const HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); -- cgit v1.2.3 From 6f9f89ee71751a0e88bbda91fef1a575a5a68ed9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 Jul 2015 16:47:07 -0400 Subject: Backed out changeset 6e1fa9518747: reapply 'selfless' changes --- indra/llmessage/llcorehttputil.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index ac1c2f8e58..cd3c527241 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -596,7 +596,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); return results; @@ -697,7 +697,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -735,7 +735,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -790,7 +790,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; -- cgit v1.2.3 From efa9a0f99c17b2b937120bcad6e3d45944122ed9 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 10 Jul 2015 19:30:10 -0400 Subject: Backed out changeset bab1000e1b2d: restore 'selfless' changes --- indra/llmessage/llcorehttputil.cpp | 72 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 4ec01aa405..ac1c2f8e58 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -565,17 +565,17 @@ HttpCoroutineAdapter::~HttpCoroutineAdapter() cancelYieldingOperation(); } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(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)); - return postAndYield_(self, request, url, body, options, headers, httpHandler); + return postAndYield_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(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) @@ -596,35 +596,35 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); return results; } -LLSD HttpCoroutineAdapter::postAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postAndYield(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)); - return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); + return postAndYield_(request, url, rawbody, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::postRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postRawAndYield(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)); - return postAndYield_(self, request, url, rawbody, options, headers, httpHandler); + return postAndYield_(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(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, const std::string & url, std::string fileName, LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) { @@ -648,12 +648,12 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe } } - return postAndYield(self, request, url, fileData, options, headers); + return postAndYield(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(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::postFileAndYield(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 +673,11 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCoros::self & self, LLCore::HttpRe delete[] fileBuffer; } - return postAndYield(self, request, url, fileData, options, headers); + return postAndYield(request, url, fileData, options, headers); } -LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::postAndYield_(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) @@ -697,24 +697,24 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::putAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::putAndYield(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)); - return putAndYield_(self, request, url, body, options, headers, httpHandler); + return putAndYield_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::putAndYield_(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) @@ -735,43 +735,43 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCoros::self & self, LLCore::HttpReques } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::getAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getAndYield(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)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getRawAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getRawAndYield(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)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getJsonAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::getJsonAndYield(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)); - return getAndYield_(self, request, url, options, headers, httpHandler); + return getAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -790,24 +790,24 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } -LLSD HttpCoroutineAdapter::deleteAndYield(LLCoros::self & self, LLCore::HttpRequest::ptr_t request, +LLSD HttpCoroutineAdapter::deleteAndYield(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)); - return deleteAndYield_(self, request, url, options, headers, httpHandler); + return deleteAndYield_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpRequest::ptr_t &request, +LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) { @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(self, handler->getReplyPump()); + LLSD results = waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -907,7 +907,7 @@ LLCore::HttpStatus HttpCoroutineAdapter::getStatusFromLLSD(const LLSD &httpResul void HttpCoroutineAdapter::callbackHttpGet(const std::string &url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericGetCoro", - boost::bind(&HttpCoroutineAdapter::trivialGetCoro, _1, url, policyId, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialGetCoro, url, policyId, success, failure)); } /*static*/ @@ -921,7 +921,7 @@ void HttpCoroutineAdapter::messageHttpGet(const std::string &url, const std::str } /*static*/ -void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericGetCoro", policyId)); @@ -932,7 +932,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, LL_INFOS("HttpCoroutineAdapter", "genericGetCoro") << "Generic GET for " << url << LL_ENDL; - LLSD result = httpAdapter->getAndYield(self, httpRequest, url, httpOpts); + LLSD result = httpAdapter->getAndYield(httpRequest, url, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -957,7 +957,7 @@ void HttpCoroutineAdapter::trivialGetCoro(LLCoros::self& self, std::string url, void HttpCoroutineAdapter::callbackHttpPost(const std::string &url, LLCore::HttpRequest::policy_t policyId, const LLSD &postData, completionCallback_t success, completionCallback_t failure) { LLCoros::instance().launch("HttpCoroutineAdapter::genericPostCoro", - boost::bind(&HttpCoroutineAdapter::trivialPostCoro, _1, url, policyId, postData, success, failure)); + boost::bind(&HttpCoroutineAdapter::trivialPostCoro, url, policyId, postData, success, failure)); } /*static*/ @@ -972,7 +972,7 @@ void HttpCoroutineAdapter::messageHttpPost(const std::string &url, const LLSD &p } /*static*/ -void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) +void HttpCoroutineAdapter::trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure) { LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", policyId)); @@ -983,7 +983,7 @@ void HttpCoroutineAdapter::trivialPostCoro(LLCoros::self& self, std::string url, LL_INFOS("HttpCoroutineAdapter", "genericPostCoro") << "Generic POST for " << url << LL_ENDL; - LLSD result = httpAdapter->postAndYield(self, httpRequest, url, postData, httpOpts); + LLSD result = httpAdapter->postAndYield(httpRequest, url, postData, httpOpts); LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); -- cgit v1.2.3 From f1be78f7e235bfe9395eed748154d77763d5ea65 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Sat, 11 Jul 2015 08:06:15 -0400 Subject: MAINT-5351: Finish messy merge restoring 'selfless' changes. --- indra/llmessage/llcorehttputil.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 05d74a45a2..a6ed287aeb 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -596,7 +596,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); return results; @@ -697,7 +697,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; @@ -735,7 +735,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -790,7 +790,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; @@ -825,7 +825,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, } saveState(hhandle, request, handler); - LLSD results = waitForEventOn(handler->getReplyPump()); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; -- cgit v1.2.3 From 96d04a050b4eee3fc0e0728043d5aa960d06eb9e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 30 Jul 2015 16:13:56 -0700 Subject: Added patchAndYield to httputil adapter Converted All AISv3 commands (except copyLibrary) to coro model. --- indra/llmessage/llcorehttputil.cpp | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index a6ed287aeb..50c866f370 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -831,6 +831,44 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, return results; } +LLSD HttpCoroutineAdapter::patchAndYield(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)); + + return patchAndYield_(request, url, body, options, headers, httpHandler); +} + + +LLSD HttpCoroutineAdapter::patchAndYield_(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) +{ + 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 = requestPatchWithLLSD(request, + mPolicyId, mPriority, url, body, 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(); + //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; +} + void HttpCoroutineAdapter::checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers) { if (!headers) @@ -839,6 +877,10 @@ void HttpCoroutineAdapter::checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &heade { headers->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML); } + if (!headers->find(HTTP_OUT_HEADER_CONTENT_TYPE)) + { + headers->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); + } if (!headers->find("X-SecondLife-UDP-Listen-Port") && gMessageSystem) { -- cgit v1.2.3 From 248d61fe0eadd128c7704e37922ba7fdef35d630 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 12 Aug 2015 16:32:49 -0700 Subject: 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 --- indra/llmessage/llcorehttputil.cpp | 94 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 5 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') 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) -- cgit v1.2.3 From 6a204b1bddc711b768d598c6ac0a16413f48d3c3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 10 Sep 2015 16:48:01 -0700 Subject: MAINT-5575: Finished converting experience cache to singleton MAINT-4952: Coverted VMM to coroutines --- indra/llmessage/llcorehttputil.cpp | 106 ++++++++++++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 12 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index d342888255..4c2e2c5ee7 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 @@ -570,7 +571,7 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, 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); } @@ -607,7 +608,7 @@ LLSD HttpCoroutineAdapter::postAndYield(LLCore::HttpRequest::ptr_t request, 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); } @@ -617,7 +618,7 @@ LLSD HttpCoroutineAdapter::postRawAndYield(LLCore::HttpRequest::ptr_t request, 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); } @@ -676,6 +677,28 @@ LLSD HttpCoroutineAdapter::postFileAndYield(LLCore::HttpRequest::ptr_t request, return postAndYield(request, url, fileData, options, headers); } +LLSD HttpCoroutineAdapter::postJsonAndYield(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 postAndYield_(request, url, rawbody, options, headers, httpHandler); +} + LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::BufferArray::ptr_t &rawbody, @@ -708,11 +731,32 @@ LLSD HttpCoroutineAdapter::putAndYield(LLCore::HttpRequest::ptr_t request, 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); } +LLSD HttpCoroutineAdapter::putJsonAndYield(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 putAndYield_(request, url, rawbody, options, headers, httpHandler); +} + LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, const LLSD & body, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, @@ -740,12 +784,39 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, return results; } +LLSD HttpCoroutineAdapter::putAndYield_(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.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::getAndYield(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); } @@ -755,7 +826,7 @@ LLSD HttpCoroutineAdapter::getRawAndYield(LLCore::HttpRequest::ptr_t request, 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); } @@ -764,7 +835,7 @@ LLSD HttpCoroutineAdapter::getJsonAndYield(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); } @@ -801,11 +872,22 @@ LLSD HttpCoroutineAdapter::deleteAndYield(LLCore::HttpRequest::ptr_t request, 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); +} + +LLSD HttpCoroutineAdapter::deleteJsonAndYield(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 deleteAndYield_(request, url, options, headers, httpHandler); } + LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler) @@ -835,7 +917,7 @@ LLSD HttpCoroutineAdapter::patchAndYield(LLCore::HttpRequest::ptr_t request, 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); } @@ -873,7 +955,7 @@ LLSD HttpCoroutineAdapter::copyAndYield(LLCore::HttpRequest::ptr_t request, 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); @@ -915,7 +997,7 @@ LLSD HttpCoroutineAdapter::moveAndYield(LLCore::HttpRequest::ptr_t request, 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); -- cgit v1.2.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/llcorehttputil.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llmessage/llcorehttputil.cpp') 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; -- cgit v1.2.3 From 75c6549fde060e974c90636685962ee373f94202 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 18 Sep 2015 11:39:22 -0700 Subject: Set consistent terminology for yield/wait -> suspend for coroutines. --- indra/llmessage/llcorehttputil.cpp | 108 ++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 54 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 106df15bf1..d964ff7100 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -567,20 +567,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(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) @@ -601,35 +601,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(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(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) { @@ -653,12 +653,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) { @@ -678,10 +678,10 @@ 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::postJsonAndYield(LLCore::HttpRequest::ptr_t request, +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) { @@ -700,11 +700,11 @@ LLSD HttpCoroutineAdapter::postJsonAndYield(LLCore::HttpRequest::ptr_t request, outs << writer.write(root); } - return postAndYield_(request, url, rawbody, options, headers, httpHandler); + 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) @@ -724,23 +724,23 @@ 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(new HttpCoroLLSDHandler(replyPump)); - return putAndYield_(request, url, body, options, headers, httpHandler); + return putAndSuspend_(request, url, body, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::putJsonAndYield(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) { @@ -758,10 +758,10 @@ LLSD HttpCoroutineAdapter::putJsonAndYield(LLCore::HttpRequest::ptr_t request, outs << writer.write(root); } - return putAndYield_(request, url, rawbody, options, headers, httpHandler); + return putAndSuspend_(request, url, rawbody, options, headers, httpHandler); } -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, HttpCoroHandler::ptr_t &handler) @@ -782,13 +782,13 @@ 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::putAndYield_(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) @@ -808,44 +808,44 @@ 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::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(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(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(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) @@ -864,35 +864,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(new HttpCoroLLSDHandler(replyPump)); - return deleteAndYield_(request, url, options, headers, httpHandler); + return deleteAndSuspend_(request, url, options, headers, httpHandler); } -LLSD HttpCoroutineAdapter::deleteJsonAndYield(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 deleteAndYield_(request, url, options, headers, httpHandler); + return deleteAndSuspend_(request, url, options, headers, httpHandler); } -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, HttpCoroHandler::ptr_t &handler) { @@ -910,24 +910,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(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) @@ -948,13 +948,13 @@ 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) { @@ -965,11 +965,11 @@ LLSD HttpCoroutineAdapter::copyAndYield(LLCore::HttpRequest::ptr_t request, 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) @@ -990,13 +990,13 @@ 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) { @@ -1007,11 +1007,11 @@ LLSD HttpCoroutineAdapter::moveAndYield(LLCore::HttpRequest::ptr_t request, 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) @@ -1032,7 +1032,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; @@ -1059,7 +1059,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(); @@ -1144,7 +1144,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); @@ -1195,7 +1195,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); -- cgit v1.2.3 From edd23c42fa3dc1ac7baa06fb2e02e1a602030a75 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 6 Oct 2015 14:17:37 -0700 Subject: MAINT-5693: Consolidated the avatar appearance request into a coroutine. If the request fails because of a stale COF, then rerequest with the corrected one. --- indra/llmessage/llcorehttputil.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index d964ff7100..db1cfbe638 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -263,8 +263,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]; @@ -276,10 +274,11 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons bas >> std::noskipws; bodyData.assign(std::istream_iterator(bas), std::istream_iterator()); 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); } -- cgit v1.2.3 From 1356be0fe9e15c8205e660e491185827d74bcb07 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 7 Oct 2015 16:09:08 -0700 Subject: MAINT-5691: Browser was using deprecated outbox display type AND not correctly returning error body to application. LLCore:HTTP now will provide and LLSD translation of the message body when possible in the case of an error HTTP result VMM alert boxes now use type="alertmodal" rather than "outbox" --- indra/llmessage/llcorehttputil.cpp | 92 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index db1cfbe638..a93bc03edd 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -249,12 +249,30 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons if (!status) { result = LLSD::emptyMap(); + LLCore::HttpStatus::type_enum_t errType = status.getType(); + LL_WARNS() << "\n--------------------------------------------------------------------------\n" - << " Error[" << status.getType() << "] cannot access url '" << response->getRequestURL() + << " Error[" << errType << "] cannot access url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; + if ((errType >= 400) && (errType < 500)) + { + LLSD body = this->parseBody(response); + if (!body.isUndefined()) + { + if (!body.isMap()) + { + result[HttpCoroutineAdapter::HTTP_RESULTS_CONTENT] = body; + } + else + { + result = body; + } + } + + } } else { @@ -344,6 +362,7 @@ public: protected: virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); + virtual LLSD parseBody(LLCore::HttpResponse *response); }; //------------------------------------------------------------------------- @@ -357,8 +376,12 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: { LLSD result; - const bool emit_parse_errors = false; +// const bool emit_parse_errors = false; + + + result = parseBody(response); +#if 0 bool parsed = !((response->getBodySize() == 0) || !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, result)); @@ -378,9 +401,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 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(); @@ -397,6 +437,22 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: return result; } +LLSD HttpCoroLLSDHandler::parseBody(LLCore::HttpResponse *response) +{ + if (response->getBodySize() == 0) + return LLSD(); + + LLSD result; + + if (!LLCoreHttpUtil::responseToLLSD(response, true, result)) + { + return LLSD(); + } + + return result; +} + + //======================================================================== /// The HttpCoroRawHandler is a specialization of the LLCore::HttpHandler for /// interacting with coroutines. @@ -411,6 +467,7 @@ public: HttpCoroRawHandler(LLEventStream &reply); virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); + virtual LLSD parseBody(LLCore::HttpResponse *response); }; //------------------------------------------------------------------------- @@ -465,6 +522,11 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: return result; } +LLSD HttpCoroRawHandler::parseBody(LLCore::HttpResponse *response) +{ + return LLSD(); +} + //======================================================================== /// The HttpCoroJSONHandler is a specialization of the LLCore::HttpHandler for /// interacting with coroutines. @@ -479,6 +541,7 @@ public: HttpCoroJSONHandler(LLEventStream &reply); virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); + virtual LLSD parseBody(LLCore::HttpResponse *response); }; //------------------------------------------------------------------------- @@ -516,6 +579,29 @@ LLSD HttpCoroJSONHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: return result; } +LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response) +{ + 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) + { + return LLSD(); + } + + // Convert the JSON structure to LLSD + return LlsdFromJson(jsonRoot); +} //======================================================================== HttpRequestPumper::HttpRequestPumper(const LLCore::HttpRequest::ptr_t &request) : -- cgit v1.2.3 From bbb9d4f21b018bfffc41f790aab7b54975504027 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 14 Oct 2015 17:46:24 -0700 Subject: MAINT-5732: Change to the way event polling handles error conditions and cancel calls. Refactor any remaining LLCore::HTTPHandlers to use boost::shared_ptr Started minor refactor in the materials manager into coroutines (unfinished) --- indra/llmessage/llcorehttputil.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index a93bc03edd..9d3b8fcc1e 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -109,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); @@ -136,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); @@ -162,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); @@ -253,7 +253,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons LL_WARNS() << "\n--------------------------------------------------------------------------\n" - << " Error[" << errType << "] cannot access url '" << response->getRequestURL() + << " Error[" << status.toTerseString() << "] cannot access url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; @@ -678,7 +678,7 @@ LLSD HttpCoroutineAdapter::postAndSuspend_(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) { @@ -801,7 +801,7 @@ LLSD HttpCoroutineAdapter::postAndSuspend_(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) { @@ -859,7 +859,7 @@ LLSD HttpCoroutineAdapter::putAndSuspend_(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) { @@ -885,7 +885,7 @@ LLSD HttpCoroutineAdapter::putAndSuspend_(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->requestPut(mPolicyId, mPriority, - url, rawbody.get(), options, headers, handler.get()); + url, rawbody.get(), options, headers, handler); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -941,7 +941,7 @@ LLSD HttpCoroutineAdapter::getAndSuspend_(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) { @@ -987,7 +987,7 @@ LLSD HttpCoroutineAdapter::deleteAndSuspend_(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) { @@ -1025,7 +1025,7 @@ LLSD HttpCoroutineAdapter::patchAndSuspend_(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) { @@ -1067,7 +1067,7 @@ LLSD HttpCoroutineAdapter::copyAndSuspend_(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) { @@ -1109,7 +1109,7 @@ LLSD HttpCoroutineAdapter::moveAndSuspend_(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) { @@ -1152,7 +1152,7 @@ void HttpCoroutineAdapter::cancelSuspendedOperation() { cleanState(); LL_INFOS() << "Canceling yielding request!" << LL_ENDL; - request->requestCancel(mYieldingHandle, handler.get()); + request->requestCancel(mYieldingHandle, handler); } } -- cgit v1.2.3 From d64ddb54caacc3d07448d4bf4a90edd3d148cc4f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 3 Nov 2015 14:22:42 -0800 Subject: MAINT-5820: Add a success/failure result to HTTP body parse method and react to that rather than an "undefined" LLSD --- indra/llmessage/llcorehttputil.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'indra/llmessage/llcorehttputil.cpp') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 9d3b8fcc1e..9a23ede81b 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -248,6 +248,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons if (!status) { + bool parseSuccess(false); result = LLSD::emptyMap(); LLCore::HttpStatus::type_enum_t errType = status.getType(); @@ -259,7 +260,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons << LL_ENDL; if ((errType >= 400) && (errType < 500)) { - LLSD body = this->parseBody(response); + LLSD body = this->parseBody(response, parseSuccess); if (!body.isUndefined()) { if (!body.isMap()) @@ -362,7 +363,7 @@ public: protected: virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); - virtual LLSD parseBody(LLCore::HttpResponse *response); + virtual LLSD parseBody(LLCore::HttpResponse *response, bool &success); }; //------------------------------------------------------------------------- @@ -377,9 +378,9 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: LLSD result; // const bool emit_parse_errors = false; + bool success(false); - - result = parseBody(response); + result = parseBody(response, success); #if 0 bool parsed = !((response->getBodySize() == 0) || @@ -403,7 +404,7 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: } #endif - if (result.isUndefined()) + if (!success) { #if 1 // Only emit a warning if we failed to parse when 'content-type' == 'application/llsd+xml' @@ -437,8 +438,9 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: return result; } -LLSD HttpCoroLLSDHandler::parseBody(LLCore::HttpResponse *response) +LLSD HttpCoroLLSDHandler::parseBody(LLCore::HttpResponse *response, bool &success) { + success = true; if (response->getBodySize() == 0) return LLSD(); @@ -446,6 +448,7 @@ LLSD HttpCoroLLSDHandler::parseBody(LLCore::HttpResponse *response) if (!LLCoreHttpUtil::responseToLLSD(response, true, result)) { + success = false; return LLSD(); } @@ -467,7 +470,7 @@ public: HttpCoroRawHandler(LLEventStream &reply); virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); - virtual LLSD parseBody(LLCore::HttpResponse *response); + virtual LLSD parseBody(LLCore::HttpResponse *response, bool &success); }; //------------------------------------------------------------------------- @@ -522,8 +525,9 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: return result; } -LLSD HttpCoroRawHandler::parseBody(LLCore::HttpResponse *response) +LLSD HttpCoroRawHandler::parseBody(LLCore::HttpResponse *response, bool &success) { + success = true; return LLSD(); } @@ -541,7 +545,7 @@ public: HttpCoroJSONHandler(LLEventStream &reply); virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); - virtual LLSD parseBody(LLCore::HttpResponse *response); + virtual LLSD parseBody(LLCore::HttpResponse *response, bool &success); }; //------------------------------------------------------------------------- @@ -579,8 +583,9 @@ LLSD HttpCoroJSONHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: return result; } -LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response) +LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response, bool &success) { + success = true; BufferArray * body(response->getBody()); if (!body || !body->size()) { @@ -596,6 +601,7 @@ LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response) } catch (std::runtime_error e) { + success = false; return LLSD(); } -- cgit v1.2.3