summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRider Linden <none@none>2015-03-26 13:32:09 -0700
committerRider Linden <none@none>2015-03-26 13:32:09 -0700
commit97b93179692b764aba7eee571f1b557f6f8070db (patch)
tree73b3d56746f86542833513fd315abc6e575b6e65 /indra
parentf6ba7514d2392bfb5bbbe8b003b4b860118fddc5 (diff)
Create trivial handler for SD Messages, method in LLAgent for posting HTTP requests.
Diffstat (limited to 'indra')
-rw-r--r--indra/llmessage/llhttpsdhandler.cpp21
-rw-r--r--indra/llmessage/llhttpsdhandler.h20
-rwxr-xr-xindra/newview/llagent.cpp35
-rwxr-xr-xindra/newview/llagent.h15
-rwxr-xr-xindra/newview/llappcorehttp.cpp6
-rwxr-xr-xindra/newview/llappcorehttp.h2
-rwxr-xr-xindra/newview/llappearancemgr.cpp3
7 files changed, 88 insertions, 14 deletions
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;
+}
diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h
index 7b7da61b3c..b3eb7d6145 100644
--- a/indra/llmessage/llhttpsdhandler.h
+++ b/indra/llmessage/llhttpsdhandler.h
@@ -30,8 +30,12 @@
#include "httphandler.h"
#include "lluri.h"
+/// Handler class LLCore's HTTP library. Splitting with separate success and
+/// failure routines and parsing the result body into LLSD on success. It
+/// is intended to be subclassed for specific capability handling.
///
-///
+// *TODO: This class self deletes at the end of onCompleted method. This is
+// less than ideal and should be revisited.
class LLHttpSDHandler : public LLCore::HttpHandler
{
public:
@@ -52,5 +56,19 @@ private:
LLURI mUri;
};
+/// A trivial implementation of LLHttpSDHandler. This success and failure
+/// methods log the action taken, the URI accessed and the status code retuned
+/// in the response.
+class LLHttpSDGenericHandler : public LLHttpSDHandler
+{
+public:
+ LLHttpSDGenericHandler(const LLURI &uri, const std::string &action);
+
+protected:
+ virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content);
+ virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status);
+private:
+ std::string mCaps;
+};
#endif \ No newline at end of file
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp
index ff0e2c42c1..81387fb927 100755
--- a/indra/newview/llagent.cpp
+++ b/indra/newview/llagent.cpp
@@ -472,7 +472,7 @@ void LLAgent::init()
mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest());
mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false);
mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false);
- mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AVATAR);
+ mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT);
doOnIdleRepeating(boost::bind(&LLAgent::onIdle, this));
@@ -2563,7 +2563,7 @@ protected:
virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status);
private:
- U8 LLMaturityHttpHandler::parseMaturityFromServerResponse(const LLSD &pContent) const;
+ U8 parseMaturityFromServerResponse(const LLSD &pContent) const;
LLAgent * mAgent;
U8 mPreferredMaturity;
@@ -2774,20 +2774,39 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity)
LL_INFOS() << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity)
<< "' via capability to: " << url << LL_ENDL;
- LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest,
- mHttpPolicy, mHttpPriority, url,
- postData, mHttpOptions, mHttpHeaders, handler);
+ LLCore::HttpHandle handle = requestPostCapibility("UpdateAgentInformation", url, postData, handler);
if (handle == LLCORE_HTTP_HANDLE_INVALID)
{
delete handler;
- LLCore::HttpStatus status = mHttpRequest->getStatus();
- LL_WARNS("Avatar") << "Maturity request post failed Reason " << status.toTerseString()
- << " \"" << status.toString() << "\"" << LL_ENDL;
+ LL_WARNS("Avatar") << "Maturity request post failed." << LL_ENDL;
}
}
}
+LLCore::HttpHandle LLAgent::requestPostCapibility(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr)
+{
+ LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(url, cap);
+ LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest,
+ mHttpPolicy, mHttpPriority, url,
+ postData, mHttpOptions, mHttpHeaders, handler);
+
+ if (handle == LLCORE_HTTP_HANDLE_INVALID)
+ {
+ if (!usrhndlr)
+ delete handler;
+ LLCore::HttpStatus status = mHttpRequest->getStatus();
+ LL_WARNS("Avatar") << "'" << cap << "' request POST failed. Reason "
+ << status.toTerseString() << " \"" << status.toString() << "\"" << LL_ENDL;
+ }
+ return handle;
+}
+
+//LLCore::HttpHandle LLAgent::httpGetCapibility(const std::string &cap, const LLURI &uri, LLHttpSDHandler *usrhndlr)
+//{
+//}
+
+
BOOL LLAgent::getAdminOverride() const
{
return mAgentAccess->getAdminOverride();
diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h
index 278e4c0fa1..6b636a2dc0 100755
--- a/indra/newview/llagent.h
+++ b/indra/newview/llagent.h
@@ -63,6 +63,7 @@ class LLSLURL;
class LLPauseRequestHandle;
class LLUIColor;
class LLTeleportRequest;
+class LLHttpSDHandler;
typedef boost::shared_ptr<LLTeleportRequest> LLTeleportRequestPtr;
@@ -919,6 +920,20 @@ public:
/********************************************************************************
** **
+ ** UTILITY
+ **/
+public:
+ /// Utilities for allowing the the agent sub managers to post and get via
+ /// HTTP using the agent's policy settings and headers.
+ LLCore::HttpHandle requestPostCapibility(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr = NULL);
+ //LLCore::HttpHandle httpGetCapibility(const std::string &cap, const LLURI &uri, LLHttpSDHandler *usrhndlr = NULL);
+
+/** Utility
+ ** **
+ *******************************************************************************/
+
+/********************************************************************************
+ ** **
** DEBUGGING
**/
diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp
index 8da78a45a6..cd9166f7b7 100755
--- a/indra/newview/llappcorehttp.cpp
+++ b/indra/newview/llappcorehttp.cpp
@@ -103,10 +103,10 @@ static const struct
"RenderMaterials",
"material manager requests"
},
- { // AP_AVATAR
+ { // AP_AGENT
2, 1, 32, 0, true,
- "Avatar",
- "Avatar requests"
+ "Agent",
+ "Agent requests"
}
};
diff --git a/indra/newview/llappcorehttp.h b/indra/newview/llappcorehttp.h
index 95b56100a6..410d7c6b07 100755
--- a/indra/newview/llappcorehttp.h
+++ b/indra/newview/llappcorehttp.h
@@ -185,7 +185,7 @@ public:
/// Concurrency: mid
/// Request rate: low
/// Pipelined: yes
- AP_AVATAR,
+ AP_AGENT,
AP_COUNT // Must be last
};
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index bb4228dbb2..ae758609ab 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -3442,6 +3442,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate()
llassert(cof_version >= gAgentAvatarp->mLastUpdateRequestCOFVersion);
gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version;
+ // *TODO: use the unified call in LLAgent (?)
LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest,
mHttpPolicy, mHttpPriority, url,
postData, mHttpOptions, mHttpHeaders, handler);
@@ -3778,7 +3779,7 @@ LLAppearanceMgr::LLAppearanceMgr():
mHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest());
mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false);
mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false);
- mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AVATAR);
+ mHttpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT);
LLOutfitObserver& outfit_observer = LLOutfitObserver::instance();
// unlock outfit on save operation completed