summaryrefslogtreecommitdiff
path: root/indra/llmessage/llhttpclient.cpp
diff options
context:
space:
mode:
authorJosh Bell <josh@lindenlab.com>2008-02-28 18:15:01 +0000
committerJosh Bell <josh@lindenlab.com>2008-02-28 18:15:01 +0000
commit2fdd7c35f33d1d98091547b8e96ad9ebf99dee47 (patch)
tree247ba5247139531ac636bb8b9db7ddf3d5ce6203 /indra/llmessage/llhttpclient.cpp
parent42bc4ba02abebced9fc3e7f91317ae293cbd20dd (diff)
svn merge -r 80357:80990 svn+ssh://svn.lindenlab.com/svn/linden/branches/Branch_1-19-1-Server --> release
Merge patches from 1.19.1 Server branch: * QAR-293 Fix for hardcoded TTLs in web dataservices * DEV-10826 fix for busted binary and notation parse if handed an unlimited parse size * Bounce apache2 processes before starting backbone/dataserver/simulator * Changing web-ds TTL in a way that any query that has 0 < ttl <=60 will have ttl = 61. * Partial reversion of multiagent-chat to 1.19.0 to address fast memory leak * Fixed minor, non user facing bug in multiagentchat * set-classified-stats: Rewrote to use new MDB2 query reformatting syntax * Fixed possible bad conversion of vivox data * DEV-550, caching changes to DirClassifieds Query * QAR-240 (DEV-8488) Prevent residents from purging stuff that isn't trash on the backend * More mem leak fixes for multiagent-chat * QAR-274 Fetch inventory descendents over TCP (via HTTP cap) instead of UDP * DEV-10151: Sometimes group IMs appear to be person to person IMs * QAR-321 Changes to crash_reporter * DEV-11004 Speed up people search query using FORCE INDEX (PRIMARY) on the username table if the first-name query fragment is >= 3 chars * DEV-11004 Speed up people search query using FORCE INDEX (PRIMARY). Web service version of this, must use two named queries because we need to change the query based on input string length.
Diffstat (limited to 'indra/llmessage/llhttpclient.cpp')
-rw-r--r--indra/llmessage/llhttpclient.cpp157
1 files changed, 32 insertions, 125 deletions
diff --git a/indra/llmessage/llhttpclient.cpp b/indra/llmessage/llhttpclient.cpp
index 23295476ff..3b892aec50 100644
--- a/indra/llmessage/llhttpclient.cpp
+++ b/indra/llmessage/llhttpclient.cpp
@@ -1,4 +1,4 @@
-/**
+ /**
* @file llhttpclient.cpp
* @brief Implementation of classes for making HTTP requests.
*
@@ -38,7 +38,6 @@
#include "llurlrequest.h"
#include "llbufferstream.h"
#include "llsdserialize.h"
-#include "llsdutil.h"
#include "llvfile.h"
#include "llvfs.h"
#include "lluri.h"
@@ -47,85 +46,18 @@
#include <curl/curl.h>
const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f;
-static std::string gCABundle;
+////////////////////////////////////////////////////////////////////////////
+// Responder class moved to LLCurl
-LLHTTPClient::Responder::Responder()
- : mReferenceCount(0)
-{
-}
-
-LLHTTPClient::Responder::~Responder()
-{
-}
-
-// virtual
-void LLHTTPClient::Responder::error(U32 status, const std::string& reason)
-{
- llinfos << "LLHTTPClient::Responder::error "
- << status << ": " << reason << llendl;
-}
-
-// virtual
-void LLHTTPClient::Responder::result(const LLSD& content)
-{
-}
-
-// virtual
-void LLHTTPClient::Responder::completedRaw(
- U32 status,
- const std::string& reason,
- const LLChannelDescriptors& channels,
- const LLIOPipe::buffer_ptr_t& buffer)
-{
- LLBufferStream istr(channels, buffer.get());
- LLSD content;
-
- if (isGoodStatus(status))
- {
- LLSDSerialize::fromXML(content, istr);
-/*
- const S32 parseError = -1;
- if(LLSDSerialize::fromXML(content, istr) == parseError)
- {
- mStatus = 498;
- mReason = "Client Parse Error";
- }
-*/
- }
-
- completed(status, reason, content);
-}
-
-// virtual
-void LLHTTPClient::Responder::completed(
- U32 status,
- const std::string& reason,
- const LLSD& content)
-{
- if(isGoodStatus(status))
- {
- result(content);
- }
- else
- {
- error(status, reason);
- }
-}
-
-// virtual
-void LLHTTPClient::Responder::completedHeader(U32 status, const std::string& reason, const LLSD& content)
-{
-
-}
namespace
{
class LLHTTPClientURLAdaptor : public LLURLRequestComplete
{
public:
- LLHTTPClientURLAdaptor(LLHTTPClient::ResponderPtr responder)
- : mResponder(responder),
- mStatus(499), mReason("LLURLRequest complete w/no status")
+ LLHTTPClientURLAdaptor(LLCurl::ResponderPtr responder)
+ : mResponder(responder), mStatus(499),
+ mReason("LLURLRequest complete w/no status")
{
}
@@ -140,7 +72,7 @@ namespace
}
virtual void complete(const LLChannelDescriptors& channels,
- const buffer_ptr_t& buffer)
+ const buffer_ptr_t& buffer)
{
if (mResponder.get())
{
@@ -154,7 +86,7 @@ namespace
}
private:
- LLHTTPClient::ResponderPtr mResponder;
+ LLCurl::ResponderPtr mResponder;
U32 mStatus;
std::string mReason;
LLSD mHeaderOutput;
@@ -267,13 +199,14 @@ namespace
LLPumpIO* theClientPump = NULL;
}
-static void request(
- const std::string& url,
- LLURLRequest::ERequestAction method,
- Injector* body_injector,
- LLHTTPClient::ResponderPtr responder,
- const LLSD& headers,
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS)
+static void request(const std::string& url,
+ LLURLRequest::ERequestAction method,
+ Injector* body_injector,
+ LLCurl::ResponderPtr responder,
+ const LLSD& headers = LLSD(),
+ const F32 timeout = HTTP_REQUEST_EXPIRY_SECS,
+ S32 offset = 0,
+ S32 bytes = 0)
{
if (!LLHTTPClient::hasPump())
{
@@ -283,7 +216,7 @@ static void request(
LLPumpIO::chain_t chain;
LLURLRequest *req = new LLURLRequest(method, url);
- req->requestEncoding("");
+ req->checkRootCertificate(true);
// Insert custom headers is the caller sent any
if (headers.isMap())
@@ -308,10 +241,6 @@ static void request(
req->addHeader(header.str().c_str());
}
}
- if (!gCABundle.empty())
- {
- req->checkRootCertificate(true, gCABundle.c_str());
- }
req->setCallback(new LLHTTPClientURLAdaptor(responder));
if (method == LLURLRequest::HTTP_POST && gMessageSystem)
@@ -327,19 +256,26 @@ static void request(
chain.push_back(LLIOPipe::ptr_t(body_injector));
}
+
+ if (method == LLURLRequest::HTTP_GET && (offset > 0 || bytes > 0))
+ {
+ std::string range = llformat("Range: bytes=%d-%d", offset,offset+bytes-1);
+ req->addHeader(range.c_str());
+ }
+
chain.push_back(LLIOPipe::ptr_t(req));
theClientPump->addChain(chain, timeout);
}
-static void request(
- const std::string& url,
- LLURLRequest::ERequestAction method,
- Injector* body_injector,
- LLHTTPClient::ResponderPtr responder,
- const F32 timeout=HTTP_REQUEST_EXPIRY_SECS)
+
+void LLHTTPClient::getByteRange(const std::string& url,
+ S32 offset, S32 bytes,
+ ResponderPtr responder,
+ const LLSD& headers,
+ const F32 timeout)
{
- request(url, method, body_injector, responder, LLSD(), timeout);
+ request(url, LLURLRequest::HTTP_GET, NULL, responder, LLSD(), timeout, offset, bytes);
}
void LLHTTPClient::head(const std::string& url, ResponderPtr responder, const F32 timeout)
@@ -355,10 +291,6 @@ void LLHTTPClient::getHeaderOnly(const std::string& url, ResponderPtr responder,
{
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);
@@ -372,11 +304,6 @@ void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr r
get(uri.asString(), responder, headers, timeout);
}
-void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const F32 timeout)
-{
- get(url, query, responder, LLSD(), timeout);
-}
-
// A simple class for managing data returned from a curl http request.
class LLHTTPBuffer
{
@@ -412,6 +339,7 @@ private:
std::string mBuffer;
};
+// *TODO: Deprecate (only used by dataserver)
// This call is blocking! This is probably usually bad. :(
LLSD LLHTTPClient::blockingGet(const std::string& url)
{
@@ -505,24 +433,3 @@ bool LLHTTPClient::hasPump()
{
return theClientPump != NULL;
}
-
-void LLHTTPClient::setCABundle(const std::string& caBundle)
-{
- gCABundle = caBundle;
-}
-
-namespace boost
-{
- void intrusive_ptr_add_ref(LLHTTPClient::Responder* p)
- {
- ++p->mReferenceCount;
- }
-
- void intrusive_ptr_release(LLHTTPClient::Responder* p)
- {
- if(p && 0 == --p->mReferenceCount)
- {
- delete p;
- }
- }
-};