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/llhttpsdhandler.cpp | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 indra/llmessage/llhttpsdhandler.cpp (limited to 'indra/llmessage/llhttpsdhandler.cpp') diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp new file mode 100644 index 0000000000..aa9801cebc --- /dev/null +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -0,0 +1,82 @@ +/** +* @file llhttpsdhandler.h +* @brief Public-facing declarations for the HttpHandler class +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "linden_common.h" +#include "llhttpconstants.h" + +#include "llhttpsdhandler.h" +#include "httpresponse.h" +#include "httpheaders.h" +#include "llsd.h" +#include "llsdserialize.h" +#include "bufferstream.h" +#include "llcorehttputil.h" + +//======================================================================== +LLHttpSDHandler::LLHttpSDHandler(const LLURI &uri): + mUri(uri) +{ + +} + +void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) +{ + LLCore::HttpStatus status = response->getStatus(); + + if (!status) + { + this->onFailure(response, status); + } + else + { + LLSD resplsd; + const bool emit_parse_errors = false; + + bool parsed = !((response->getBodySize() == 0) || + !LLCoreHttpUtil::responseToLLSD(response, emit_parse_errors, resplsd)); + + 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 . " << getUri() << " [status:" << response->getStatus().toString() << "] " + << " body: " << thebody << LL_ENDL; + } + } + + this->onSuccess(response, resplsd); + } + + // The handler must destroy itself when it is done. + delete this; +} + -- cgit v1.2.3 From e140118fc41b79e403b299cabe1653af1971e87a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 25 Mar 2015 11:31:11 -0700 Subject: Replace appearance responder with new LLCore Appearance Handler. Prep for some slight cleanup of the code. Add AP_AVATAR Policy --- indra/llmessage/llhttpsdhandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'indra/llmessage/llhttpsdhandler.cpp') diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index aa9801cebc..18daf443ee 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -76,7 +76,9 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons this->onSuccess(response, resplsd); } - // The handler must destroy itself when it is done. + // The handler must destroy itself when it is done. + // *TODO: I'm not fond of this pattern. A class shooting itself in the head + // outside of a smart pointer always makes me nervous. delete this; } -- cgit v1.2.3 From 97b93179692b764aba7eee571f1b557f6f8070db Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 26 Mar 2015 13:32:09 -0700 Subject: Create trivial handler for SD Messages, method in LLAgent for posting HTTP requests. --- indra/llmessage/llhttpsdhandler.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'indra/llmessage/llhttpsdhandler.cpp') diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 18daf443ee..0d385d6497 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -82,3 +82,24 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons delete this; } +//======================================================================== +LLHttpSDGenericHandler::LLHttpSDGenericHandler(const LLURI &uri, const std::string &caps) : + LLHttpSDHandler(uri), + mCaps(caps) +{ +} + +void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +{ + LL_DEBUGS() << mCaps << " Success." << LL_ENDL; +} + +void LLHttpSDGenericHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) +{ + LL_WARNS() + << "\n--------------------------------------------------------------------------\n" + << mCaps << " Error[" << status.toULong() << "] cannot access cap with url '" + << getUri() << "' because " << status.toString() + << "\n--------------------------------------------------------------------------" + << LL_ENDL; +} -- cgit v1.2.3 From 735364038767694ea29d9b6a168410e6482cc9c2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 27 Mar 2015 17:00:02 -0700 Subject: first set of chnages from code review from Nat --- indra/llmessage/llhttpsdhandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llmessage/llhttpsdhandler.cpp') diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 0d385d6497..72ecfe77e2 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -89,7 +89,7 @@ LLHttpSDGenericHandler::LLHttpSDGenericHandler(const LLURI &uri, const std::stri { } -void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { LL_DEBUGS() << mCaps << " Success." << LL_ENDL; } -- 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/llhttpsdhandler.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'indra/llmessage/llhttpsdhandler.cpp') diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 72ecfe77e2..159d03b176 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -36,10 +36,8 @@ #include "llcorehttputil.h" //======================================================================== -LLHttpSDHandler::LLHttpSDHandler(const LLURI &uri): - mUri(uri) +LLHttpSDHandler::LLHttpSDHandler() { - } void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) @@ -68,7 +66,7 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons { std::string thebody = LLCoreHttpUtil::responseToString(response); - LL_WARNS() << "Failed to deserialize . " << getUri() << " [status:" << response->getStatus().toString() << "] " + LL_WARNS() << "Failed to deserialize . " << response->getRequestURL() << " [status:" << response->getStatus().toString() << "] " << " body: " << thebody << LL_ENDL; } } @@ -83,8 +81,8 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons } //======================================================================== -LLHttpSDGenericHandler::LLHttpSDGenericHandler(const LLURI &uri, const std::string &caps) : - LLHttpSDHandler(uri), +LLHttpSDGenericHandler::LLHttpSDGenericHandler(const std::string &caps) : + LLHttpSDHandler(), mCaps(caps) { } @@ -99,7 +97,7 @@ void LLHttpSDGenericHandler::onFailure(LLCore::HttpResponse * response, LLCore:: LL_WARNS() << "\n--------------------------------------------------------------------------\n" << mCaps << " Error[" << status.toULong() << "] cannot access cap with url '" - << getUri() << "' because " << status.toString() + << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; } -- cgit v1.2.3 From da32de179d50d85cd815c545282d274d18c9dc3e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 28 Apr 2015 09:39:47 -0700 Subject: Converting llmediaclient to new order. Temp disable llmediaclient's unit tests for link issues. --- indra/llmessage/llhttpsdhandler.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'indra/llmessage/llhttpsdhandler.cpp') diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 159d03b176..d99bdd3f66 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -36,7 +36,8 @@ #include "llcorehttputil.h" //======================================================================== -LLHttpSDHandler::LLHttpSDHandler() +LLHttpSDHandler::LLHttpSDHandler(bool selfDelete): + mSelfDelete(selfDelete) { } @@ -77,26 +78,27 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons // The handler must destroy itself when it is done. // *TODO: I'm not fond of this pattern. A class shooting itself in the head // outside of a smart pointer always makes me nervous. - delete this; + if (mSelfDelete) + delete this; } //======================================================================== -LLHttpSDGenericHandler::LLHttpSDGenericHandler(const std::string &caps) : - LLHttpSDHandler(), - mCaps(caps) +LLHttpSDGenericHandler::LLHttpSDGenericHandler(const std::string &name, bool selfDelete): + LLHttpSDHandler(selfDelete), + mName(name) { } void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { - LL_DEBUGS() << mCaps << " Success." << LL_ENDL; + LL_DEBUGS() << mName << " Success." << LL_ENDL; } void LLHttpSDGenericHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) { LL_WARNS() << "\n--------------------------------------------------------------------------\n" - << mCaps << " Error[" << status.toULong() << "] cannot access cap with url '" + << mName << " Error[" << status.toULong() << "] cannot access cap with url '" << response->getRequestURL() << "' because " << status.toString() << "\n--------------------------------------------------------------------------" << LL_ENDL; -- cgit v1.2.3