Create trivial handler for SD Messages, method in LLAgent for posting HTTP requests.
parent
f6ba7514d2
commit
97b9317969
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ class LLSLURL;
|
|||
class LLPauseRequestHandle;
|
||||
class LLUIColor;
|
||||
class LLTeleportRequest;
|
||||
class LLHttpSDHandler;
|
||||
|
||||
typedef boost::shared_ptr<LLTeleportRequest> LLTeleportRequestPtr;
|
||||
|
||||
|
|
@ -917,6 +918,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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public:
|
|||
/// Concurrency: mid
|
||||
/// Request rate: low
|
||||
/// Pipelined: yes
|
||||
AP_AVATAR,
|
||||
AP_AGENT,
|
||||
|
||||
AP_COUNT // Must be last
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue