diff options
Diffstat (limited to 'indra/llmessage')
-rw-r--r-- | indra/llmessage/llhttpclient.cpp | 20 | ||||
-rw-r--r-- | indra/llmessage/llhttpclient.h | 11 | ||||
-rw-r--r-- | indra/llmessage/llurlrequest.cpp | 6 |
3 files changed, 30 insertions, 7 deletions
diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp index 9f6115a0e4..23295476ff 100644 --- a/indra/llmessage/llhttpclient.cpp +++ b/indra/llmessage/llhttpclient.cpp @@ -38,6 +38,7 @@ #include "llurlrequest.h" #include "llbufferstream.h" #include "llsdserialize.h" +#include "llsdutil.h" #include "llvfile.h" #include "llvfs.h" #include "lluri.h" @@ -112,7 +113,11 @@ void LLHTTPClient::Responder::completed( } } +// virtual +void LLHTTPClient::Responder::completedHeader(U32 status, const std::string& reason, const LLSD& content) +{ +} namespace { class LLHTTPClientURLAdaptor : public LLURLRequestComplete @@ -140,13 +145,19 @@ namespace if (mResponder.get()) { mResponder->completedRaw(mStatus, mReason, channels, buffer); + mResponder->completedHeader(mStatus, mReason, mHeaderOutput); } } + virtual void header(const std::string& header, const std::string& value) + { + mHeaderOutput[header] = value; + } private: LLHTTPClient::ResponderPtr mResponder; U32 mStatus; std::string mReason; + LLSD mHeaderOutput; }; class Injector : public LLIOPipe @@ -340,11 +351,18 @@ void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLS { request(url, LLURLRequest::HTTP_GET, NULL, responder, headers, timeout); } - +void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout) +{ + request(url, LLURLRequest::HTTP_HEAD, NULL, responder, headers, timeout); +} void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const F32 timeout) { get(url, responder, LLSD(), timeout); } +void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder, const F32 timeout) +{ + getHeaderOnly(url, responder, LLSD(), timeout); +} void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const LLSD& headers, const F32 timeout) { diff --git a/indra/llmessage/llhttpclient.h b/indra/llmessage/llhttpclient.h index 983ff46e03..1fbf0c36dc 100644 --- a/indra/llmessage/llhttpclient.h +++ b/indra/llmessage/llhttpclient.h @@ -89,7 +89,11 @@ public: * result(), or * error() */ - + + // Override to handle parsing of the header only. Note: this is the only place where the contents + // of the header can be parsed. In the ::completed call above only the body is contained in the LLSD. + virtual void completedHeader(U32 status, const std::string& reason, const LLSD& content); + public: /* but not really -- don't touch this */ U32 mReferenceCount; }; @@ -102,7 +106,10 @@ public: static void get(const std::string& url, const LLSD& query, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void get(const std::string& url, const LLSD& query, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void put(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); - ///< non-blocking + static void getHeaderOnly(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); + static void getHeaderOnly(const std::string& url, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); + + ///< non-blocking static void post(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void post(const std::string& url, const U8* data, S32 size, ResponderPtr responder, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void postFile(const std::string& url, const std::string& filename, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp index 1cdaa1687d..631eea3e88 100644 --- a/indra/llmessage/llurlrequest.cpp +++ b/indra/llmessage/llurlrequest.cpp @@ -429,12 +429,10 @@ bool LLURLRequest::configure() switch(mAction) { case HTTP_HEAD: + // These are in addition to the HTTP_GET options. curl_easy_setopt(mDetail->mCurl, CURLOPT_HEADER, 1); curl_easy_setopt(mDetail->mCurl, CURLOPT_NOBODY, 1); - curl_easy_setopt(mDetail->mCurl, CURLOPT_FOLLOWLOCATION, 1); - rv = true; - break; - + case HTTP_GET: curl_easy_setopt(mDetail->mCurl, CURLOPT_HTTPGET, 1); curl_easy_setopt(mDetail->mCurl, CURLOPT_FOLLOWLOCATION, 1); |