summaryrefslogtreecommitdiff
path: root/indra/newview/llmaterialmgr.cpp
diff options
context:
space:
mode:
authorRider Linden <none@none>2015-03-19 17:01:21 -0700
committerRider Linden <none@none>2015-03-19 17:01:21 -0700
commit6b8c814df3141fa705b9921ba0a73aeaa3fe63b6 (patch)
treecd17b4e5f83159fc0d9f0c2a9ecc537e3413ddc6 /indra/newview/llmaterialmgr.cpp
parent6f4d36634e980bb989b9a8b762c3c622804c43dd (diff)
Adding new HTTP handling for material manager.
Diffstat (limited to 'indra/newview/llmaterialmgr.cpp')
-rwxr-xr-xindra/newview/llmaterialmgr.cpp124
1 files changed, 90 insertions, 34 deletions
diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp
index a1f6a01aa0..f43efd75b8 100755
--- a/indra/newview/llmaterialmgr.cpp
+++ b/indra/newview/llmaterialmgr.cpp
@@ -36,6 +36,10 @@
#include "llviewerobjectlist.h"
#include "llviewerregion.h"
#include "llworld.h"
+#include "llhttpsdhandler.h"
+#include "httpcommon.h"
+#include "httpheaders.h"
+#include "llcorehttputil.h"
/**
* Materials cap parameters
@@ -59,56 +63,51 @@
#define MATERIALS_PUT_THROTTLE_SECS 1.f
#define MATERIALS_PUT_MAX_ENTRIES 50
-/**
- * LLMaterialsResponder helper class
- */
-class LLMaterialsResponder : public LLHTTPClient::Responder
+
+class LLMaterialHttpHandler : public LLHttpSDHandler
{
-public:
- typedef boost::function<void (bool, const LLSD&)> CallbackFunction;
+public:
+ typedef boost::function<void(bool, const LLSD&)> CallbackFunction;
+ typedef boost::shared_ptr<LLMaterialHttpHandler> ptr_t;
+
+ LLMaterialHttpHandler(const std::string& method, const std::string& capabilityURL, CallbackFunction cback);
- LLMaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback);
- virtual ~LLMaterialsResponder();
+ virtual ~LLMaterialHttpHandler();
- virtual void httpSuccess();
- virtual void httpFailure();
+protected:
+ virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content);
+ virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status);
private:
std::string mMethod;
- std::string mCapabilityURL;
CallbackFunction mCallback;
};
-LLMaterialsResponder::LLMaterialsResponder(const std::string& pMethod, const std::string& pCapabilityURL, CallbackFunction pCallback)
- : LLHTTPClient::Responder()
- , mMethod(pMethod)
- , mCapabilityURL(pCapabilityURL)
- , mCallback(pCallback)
+LLMaterialHttpHandler::LLMaterialHttpHandler(const std::string& method, const std::string& capabilityURL, CallbackFunction cback):
+ LLHttpSDHandler(capabilityURL),
+ mMethod(method),
+ mCallback(cback)
{
+
}
-LLMaterialsResponder::~LLMaterialsResponder()
+LLMaterialHttpHandler::~LLMaterialHttpHandler()
{
}
-void LLMaterialsResponder::httpSuccess()
+void LLMaterialHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content)
{
- const LLSD& pContent = getContent();
-
LL_DEBUGS("Materials") << LL_ENDL;
- mCallback(true, pContent);
+ mCallback(true, content);
}
-void LLMaterialsResponder::httpFailure()
+void LLMaterialHttpHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status)
{
- U32 pStatus = (U32) getStatus();
- const std::string& pReason = getReason();
-
LL_WARNS("Materials")
<< "\n--------------------------------------------------------------------------\n"
- << mMethod << " Error[" << pStatus << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME
- << "'\n with url '" << mCapabilityURL << "' because " << pReason
+ << mMethod << " Error[" << status.toULong() << "] cannot access cap '" << MATERIALS_CAPABILITY_NAME
+ << "'\n with url '" << getUri() << "' because " << status.toString()
<< "\n--------------------------------------------------------------------------"
<< LL_ENDL;
@@ -116,12 +115,16 @@ void LLMaterialsResponder::httpFailure()
mCallback(false, emptyResult);
}
+
+
/**
* LLMaterialMgr class
*/
LLMaterialMgr::LLMaterialMgr()
{
+ mRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest());
+
mMaterials.insert(std::pair<LLMaterialID, LLMaterialPtr>(LLMaterialID::null, LLMaterialPtr(NULL)));
gIdleCallbacks.addFunction(&LLMaterialMgr::onIdle, NULL);
LLWorld::instance().setRegionRemovedCallback(boost::bind(&LLMaterialMgr::onRegionRemoved, this, _1));
@@ -554,6 +557,8 @@ void LLMaterialMgr::onIdle(void*)
{
instancep->processPutQueue();
}
+
+ instancep->mRequest->update(0L);
}
void LLMaterialMgr::processGetQueue()
@@ -629,10 +634,28 @@ void LLMaterialMgr::processGetQueue()
LLSD postData = LLSD::emptyMap();
postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary;
- LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("POST", capURL, boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id));
- LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '"<< capURL << " for " << materialsData.size() << " materials."
+ LLMaterialHttpHandler * handler =
+ new LLMaterialHttpHandler("POST", capURL,
+ boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id)
+ );
+
+ LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false);
+
+ LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '" << capURL << " for " << materialsData.size() << " materials."
<< "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL;
- LLHTTPClient::post(capURL, postData, materialsResponder);
+
+ LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD(mRequest.get(),
+ LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, capURL,
+ postData, NULL, headers.get(), handler);
+
+ if (handle == LLCORE_HTTP_HANDLE_INVALID)
+ {
+ delete handler;
+ LLCore::HttpStatus status = mRequest->getStatus();
+ LL_ERRS("Meterials") << "Failed to execute material POST. Status = " <<
+ status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL;
+ }
+
regionp->resetMaterialsCapThrottle();
}
}
@@ -667,8 +690,24 @@ void LLMaterialMgr::processGetAllQueue()
}
LL_DEBUGS("Materials") << "GET all for region " << region_id << "url " << capURL << LL_ENDL;
- LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("GET", capURL, boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion));
- LLHTTPClient::get(capURL, materialsResponder);
+ LLMaterialHttpHandler *handler =
+ new LLMaterialHttpHandler("GET", capURL,
+ boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion)
+ );
+
+ LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false);
+
+ LLCore::HttpHandle handle = mRequest->requestGet(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0,
+ capURL, NULL, headers.get(), handler);
+
+ if (handle == LLCORE_HTTP_HANDLE_INVALID)
+ {
+ delete handler;
+ LLCore::HttpStatus status = mRequest->getStatus();
+ LL_ERRS("Meterials") << "Failed to execute material GET. Status = " <<
+ status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL;
+ }
+
regionp->resetMaterialsCapThrottle();
mGetAllPending.insert(std::pair<LLUUID, F64>(region_id, LLFrameTimer::getTotalSeconds()));
mGetAllQueue.erase(itRegion); // Invalidates region_id
@@ -755,8 +794,25 @@ void LLMaterialMgr::processPutQueue()
putData[MATERIALS_CAP_ZIP_FIELD] = materialBinary;
LL_DEBUGS("Materials") << "put for " << itRequest->second.size() << " faces to region " << itRequest->first->getName() << LL_ENDL;
- LLHTTPClient::ResponderPtr materialsResponder = new LLMaterialsResponder("PUT", capURL, boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2));
- LLHTTPClient::put(capURL, putData, materialsResponder);
+
+ LLMaterialHttpHandler * handler =
+ new LLMaterialHttpHandler("PUT", capURL,
+ boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2)
+ );
+
+ LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false);
+
+ LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD(mRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0,
+ capURL, putData, NULL, headers.get(), handler);
+
+ if (handle == LLCORE_HTTP_HANDLE_INVALID)
+ {
+ delete handler;
+ LLCore::HttpStatus status = mRequest->getStatus();
+ LL_ERRS("Meterials") << "Failed to execute material PUT. Status = " <<
+ status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL;
+ }
+
regionp->resetMaterialsCapThrottle();
}
else