diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llmessage/llcorehttputil.cpp | 73 | ||||
-rw-r--r-- | indra/llmessage/llcorehttputil.h | 12 | ||||
-rwxr-xr-x | indra/newview/llfloaterregioninfo.cpp | 64 | ||||
-rwxr-xr-x | indra/newview/llfloaterregioninfo.h | 3 |
4 files changed, 93 insertions, 59 deletions
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<LLCore::HttpStatus::type_enum_t>(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 diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index e8e5f1b1aa..7d60bfbbaf 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -387,8 +387,17 @@ public: /// void cancelYieldingOperation(); + static LLCore::HttpStatus getStatusFromLLSD(const LLSD &httpResults); + /// Generic Get and post routines for HTTP via coroutines. + /// These static methods do all required setup for the GET or POST operation. + /// When the operation completes successfully they will put the success message in the log at INFO level, + /// If the operation fails the failure message is written to the log at WARN level. + /// + static void genericHttpGet(const std::string &url, const std::string &success = std::string(), const std::string &failure = std::string()); + static void genericHttpPost(const std::string &url, const LLSD &postData, const std::string &success, const std::string &failure); + private: static LLSD buildImmediateErrorResult(const LLCore::HttpRequest::ptr_t &request, const std::string &url); @@ -419,6 +428,9 @@ private: const std::string & url, LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); + static void genericGetCoro(LLCoros::self& self, std::string &url, std::string success, std::string failure); + static void genericPostCoro(LLCoros::self& self, std::string &url, LLSD postData, std::string success, std::string failure); + std::string mAdapterName; LLCore::HttpRequest::priority_t mPriority; LLCore::HttpRequest::policy_t mPolicyId; diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index a2af9da670..42c03e22eb 100755 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -92,6 +92,7 @@ #include "llagentui.h" #include "llmeshrepository.h" #include "llfloaterregionrestarting.h" +#include "llcorehttputil.h" const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -768,30 +769,6 @@ bool LLPanelRegionGeneralInfo::onMessageCommit(const LLSD& notification, const L return false; } -class ConsoleRequestResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(ConsoleRequestResponder); -protected: - /*virtual*/ - void httpFailure() - { - LL_WARNS() << "error requesting mesh_rez_enabled " << dumpResponse() << LL_ENDL; - } -}; - - -// called if this request times out. -class ConsoleUpdateResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(ConsoleUpdateResponder); -protected: - /* virtual */ - void httpFailure() - { - LL_WARNS() << "error updating mesh enabled region setting " << dumpResponse() << LL_ENDL; - } -}; - void LLFloaterRegionInfo::requestMeshRezInfo() { std::string sim_console_url = gAgent.getRegion()->getCapability("SimConsoleAsync"); @@ -800,10 +777,8 @@ void LLFloaterRegionInfo::requestMeshRezInfo() { std::string request_str = "get mesh_rez_enabled"; - LLHTTPClient::post( - sim_console_url, - LLSD(request_str), - new ConsoleRequestResponder); + LLCoreHttpUtil::HttpCoroutineAdapter::genericHttpPost(sim_console_url, LLSD(request_str), + "Requested mesh_rez_enabled", "Error requesting mesh_rez_enabled"); } } @@ -839,7 +814,8 @@ BOOL LLPanelRegionGeneralInfo::sendUpdate() body["allow_parcel_changes"] = getChild<LLUICtrl>("allow_parcel_changes_check")->getValue(); body["block_parcel_search"] = getChild<LLUICtrl>("block_parcel_search_check")->getValue(); - LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); + LLCoreHttpUtil::HttpCoroutineAdapter::genericHttpPost(url, body, + "Region info update posted.", "Region info update not posted."); } else { @@ -2263,36 +2239,6 @@ void LLPanelEstateInfo::getEstateOwner() } */ -class LLEstateChangeInfoResponder : public LLHTTPClient::Responder -{ - LOG_CLASS(LLEstateChangeInfoResponder); -public: - LLEstateChangeInfoResponder(LLPanelEstateInfo* panel) - { - mpPanel = panel->getHandle(); - } - -protected: - // if we get a normal response, handle it here - virtual void httpSuccess() - { - LL_INFOS("Windlight") << "Successfully committed estate info" << LL_ENDL; - - // refresh the panel from the database - LLPanelEstateInfo* panel = dynamic_cast<LLPanelEstateInfo*>(mpPanel.get()); - if (panel) - panel->refresh(); - } - - // if we get an error response - virtual void httpFailure() - { - LL_WARNS("Windlight") << dumpResponse() << LL_ENDL; - } -private: - LLHandle<LLPanel> mpPanel; -}; - const std::string LLPanelEstateInfo::getOwnerName() const { return getChild<LLUICtrl>("estate_owner")->getValue().asString(); diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index 792f60ebc8..4042df21c7 100755 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -36,6 +36,7 @@ #include "llextendedstatus.h" #include "llenvmanager.h" // for LLEnvironmentSettings +#include "lleventcoro.h" class LLAvatarName; class LLDispatcher; @@ -103,6 +104,8 @@ private: LLFloaterRegionInfo(const LLSD& seed); ~LLFloaterRegionInfo(); + + protected: void onTabSelected(const LLSD& param); |