summaryrefslogtreecommitdiff
path: root/indra/llmessage
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/llmessage
parent6f4d36634e980bb989b9a8b762c3c622804c43dd (diff)
Adding new HTTP handling for material manager.
Diffstat (limited to 'indra/llmessage')
-rwxr-xr-xindra/llmessage/CMakeLists.txt2
-rw-r--r--indra/llmessage/llcorehttputil.cpp26
-rw-r--r--indra/llmessage/llcorehttputil.h25
-rwxr-xr-xindra/llmessage/llcurl.h99
-rw-r--r--indra/llmessage/llhttpsdhandler.cpp82
-rw-r--r--indra/llmessage/llhttpsdhandler.h56
6 files changed, 191 insertions, 99 deletions
diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt
index 40eddcb0ab..c5b6024b89 100755
--- a/indra/llmessage/CMakeLists.txt
+++ b/indra/llmessage/CMakeLists.txt
@@ -49,6 +49,7 @@ set(llmessage_SOURCE_FILES
llhttpclientadapter.cpp
llhttpconstants.cpp
llhttpnode.cpp
+ llhttpsdhandler.cpp
llhttpsender.cpp
llinstantmessage.cpp
lliobuffer.cpp
@@ -144,6 +145,7 @@ set(llmessage_HEADER_FILES
llhttpconstants.h
llhttpnode.h
llhttpnodeadapter.h
+ llhttpsdhandler.h
llhttpsender.h
llinstantmessage.h
llinvite.h
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp
index ee80b0fd94..1a5a6fc75f 100644
--- a/indra/llmessage/llcorehttputil.cpp
+++ b/indra/llmessage/llcorehttputil.cpp
@@ -88,6 +88,32 @@ HttpHandle requestPostWithLLSD(HttpRequest * request,
return handle;
}
+HttpHandle requestPutWithLLSD(HttpRequest * request,
+ HttpRequest::policy_t policy_id,
+ HttpRequest::priority_t priority,
+ const std::string & url,
+ const LLSD & body,
+ HttpOptions * options,
+ HttpHeaders * headers,
+ HttpHandler * handler)
+{
+ HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID);
+
+ BufferArray * ba = new BufferArray();
+ BufferArrayStream bas(ba);
+ LLSDSerialize::toXML(body, bas);
+
+ handle = request->requestPut(policy_id,
+ priority,
+ url,
+ ba,
+ options,
+ headers,
+ handler);
+ ba->release();
+ return handle;
+}
+
std::string responseToString(LLCore::HttpResponse * response)
{
diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h
index d40172bc7a..7c5a5aea61 100644
--- a/indra/llmessage/llcorehttputil.h
+++ b/indra/llmessage/llcorehttputil.h
@@ -109,6 +109,31 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request,
LLCore::HttpHeaders * headers,
LLCore::HttpHandler * handler);
+/// Issue a standard HttpRequest::requestPut() call but using
+/// and LLSD object as the request body. Conventions are the
+/// same as with that method. Caller is expected to provide
+/// an HttpHeaders object with a correct 'Content-Type:' header.
+/// One will not be provided by this call.
+///
+/// @return If request is successfully issued, the
+/// HttpHandle representing the request.
+/// On error, LLCORE_HTTP_HANDLE_INVALID
+/// is returned and caller can fetch detailed
+/// status with the getStatus() method on the
+/// request object. In case of error, no
+/// request is queued and caller may need to
+/// perform additional cleanup such as freeing
+/// a now-useless HttpHandler object.
+///
+LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request,
+ LLCore::HttpRequest::policy_t policy_id,
+ LLCore::HttpRequest::priority_t priority,
+ const std::string & url,
+ const LLSD & body,
+ LLCore::HttpOptions * options,
+ LLCore::HttpHeaders * headers,
+ LLCore::HttpHandler * handler);
+
} // end namespace LLCoreHttpUtil
diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h
index 295e9c9fe5..06b3ce45e1 100755
--- a/indra/llmessage/llcurl.h
+++ b/indra/llmessage/llcurl.h
@@ -309,7 +309,6 @@ private:
static void deleteAllFreeHandles();
};
-#if 1
class LLCurl::Multi
{
LOG_CLASS(Multi);
@@ -380,7 +379,6 @@ private:
LLFrameTimer mIdleTimer ;
F32 mIdleTimeOut;
};
-#endif
class LLCurlThread : public LLQueuedThread
{
@@ -419,103 +417,6 @@ private:
void cleanupMulti(LLCurl::Multi* multi) ;
} ;
-#if 0
-class LLCurlRequest
-{
-public:
- typedef std::vector<std::string> headers_t;
-
- LLCurlRequest();
- ~LLCurlRequest();
-
- void get(const std::string& url, LLCurl::ResponderPtr responder);
- bool getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, LLCurl::ResponderPtr responder);
- bool post(const std::string& url, const headers_t& headers, const LLSD& data, LLCurl::ResponderPtr responder, S32 time_out = 0);
- bool post(const std::string& url, const headers_t& headers, const std::string& data, LLCurl::ResponderPtr responder, S32 time_out = 0);
-
- S32 process();
- S32 getQueued();
-
-private:
- void addMulti();
- LLCurl::Easy* allocEasy();
- bool addEasy(LLCurl::Easy* easy);
-
-private:
- typedef std::set<LLCurl::Multi*> curlmulti_set_t;
- curlmulti_set_t mMultiSet;
- LLCurl::Multi* mActiveMulti;
- S32 mActiveRequestCount;
- BOOL mProcessing;
-};
-#endif
-
-#if 0
-//for texture fetch only
-class LLCurlTextureRequest : public LLCurlRequest
-{
-public:
- LLCurlTextureRequest(S32 concurrency);
- ~LLCurlTextureRequest();
-
- U32 getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder, F32 delay_time = -1.f);
- void nextRequests();
- void completeRequest(S32 received_bytes);
-
- void updatePriority(U32 handle, U32 pri);
- void removeRequest(U32 handle);
-
- U32 getTotalReceivedBits();
- U32 getTotalIssuedRequests();
- S32 getNumRequests();
- bool isWaiting(U32 handle);
-
-private:
- LLMutex mMutex;
- S32 mConcurrency;
- S32 mInQueue; //request currently in queue.
- U32 mHandleCounter;
- U32 mTotalIssuedRequests;
- U32 mTotalReceivedBits;
-
- typedef struct _request_t
- {
- _request_t(U32 handle, const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder) :
- mHandle(handle), mUrl(url), mHeaders(headers), mOffset(offset), mLength(length), mPriority(pri), mResponder(responder), mStartTime(0.f)
- {}
-
- U32 mHandle;
- std::string mUrl;
- LLCurlRequest::headers_t mHeaders;
- S32 mOffset;
- S32 mLength;
- LLCurl::ResponderPtr mResponder;
- U32 mPriority;
- F32 mStartTime; //start time to issue this request
- } request_t;
-
- struct request_compare
- {
- bool operator()(const request_t* lhs, const request_t* rhs) const
- {
- if(lhs->mPriority != rhs->mPriority)
- {
- return lhs->mPriority > rhs->mPriority; // higher priority in front of queue (set)
- }
- else
- {
- return (U32)lhs < (U32)rhs;
- }
- }
- };
-
- typedef std::set<request_t*, request_compare> req_queue_t;
- req_queue_t mCachedRequests;
- std::map<S32, request_t*> mRequestMap;
-
- LLFrameTimer mGlobalTimer;
-};
-#endif
class LLCurlEasyRequest
{
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;
+}
+
diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h
new file mode 100644
index 0000000000..7b7da61b3c
--- /dev/null
+++ b/indra/llmessage/llhttpsdhandler.h
@@ -0,0 +1,56 @@
+/**
+* @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$
+*/
+
+#ifndef _LLHTTPSDHANDLER_H_
+#define _LLHTTPSDHANDLER_H_
+#include "httpcommon.h"
+#include "httphandler.h"
+#include "lluri.h"
+
+///
+///
+class LLHttpSDHandler : public LLCore::HttpHandler
+{
+public:
+ LLHttpSDHandler(const LLURI &uri);
+
+ virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response);
+
+ inline const LLURI &getUri() const
+ {
+ return mUri;
+ }
+
+protected:
+ virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content) = 0;
+ virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) = 0;
+
+private:
+ LLURI mUri;
+};
+
+
+#endif \ No newline at end of file