summaryrefslogtreecommitdiff
path: root/indra/llcorehttp
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2015-07-08 10:01:27 -0700
committerRider Linden <rider@lindenlab.com>2015-07-08 10:01:27 -0700
commit1138c57f9a8553903199e727912d7f1b092697e4 (patch)
tree4414279316808fa7d778eb64540ba6dff07465e0 /indra/llcorehttp
parent6689c92400a42bfc005f91b00c06601c508eac64 (diff)
Convert LLCore::HttpHeaders to use shared_ptr<> rather than an intrusive_ptr<> for refrence counting.
Diffstat (limited to 'indra/llcorehttp')
-rwxr-xr-xindra/llcorehttp/_httplibcurl.cpp2
-rwxr-xr-xindra/llcorehttp/_httpoprequest.cpp41
-rwxr-xr-xindra/llcorehttp/_httpoprequest.h23
-rwxr-xr-xindra/llcorehttp/httpheaders.cpp1
-rwxr-xr-xindra/llcorehttp/httpheaders.h7
-rwxr-xr-xindra/llcorehttp/httprequest.cpp14
-rwxr-xr-xindra/llcorehttp/httprequest.h15
-rwxr-xr-xindra/llcorehttp/httpresponse.cpp21
-rwxr-xr-xindra/llcorehttp/httpresponse.h12
9 files changed, 55 insertions, 81 deletions
diff --git a/indra/llcorehttp/_httplibcurl.cpp b/indra/llcorehttp/_httplibcurl.cpp
index 81b44ab90b..17e997688f 100755
--- a/indra/llcorehttp/_httplibcurl.cpp
+++ b/indra/llcorehttp/_httplibcurl.cpp
@@ -554,7 +554,7 @@ void HttpLibcurl::HandleCache::freeHandle(CURL * handle)
// ---------------------------------------
-struct curl_slist * append_headers_to_slist(const HttpHeaders * headers, struct curl_slist * slist)
+struct curl_slist * append_headers_to_slist(const HttpHeaders::ptr_t &headers, struct curl_slist * slist)
{
const HttpHeaders::const_iterator end(headers->end());
for (HttpHeaders::const_iterator it(headers->begin()); end != it; ++it)
diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp
index 799587ff22..5d118a9afb 100755
--- a/indra/llcorehttp/_httpoprequest.cpp
+++ b/indra/llcorehttp/_httpoprequest.cpp
@@ -122,7 +122,7 @@ HttpOpRequest::HttpOpRequest()
mReqBody(NULL),
mReqOffset(0),
mReqLength(0),
- mReqHeaders(NULL),
+ mReqHeaders(),
mReqOptions(NULL),
mCurlActive(false),
mCurlHandle(NULL),
@@ -135,7 +135,7 @@ HttpOpRequest::HttpOpRequest()
mReplyOffset(0),
mReplyLength(0),
mReplyFullLength(0),
- mReplyHeaders(NULL),
+ mReplyHeaders(),
mPolicyRetries(0),
mPolicy503Retries(0),
mPolicyRetryAt(HttpTime(0)),
@@ -162,12 +162,6 @@ HttpOpRequest::~HttpOpRequest()
mReqOptions = NULL;
}
- if (mReqHeaders)
- {
- mReqHeaders->release();
- mReqHeaders = NULL;
- }
-
if (mCurlHandle)
{
// Uncertain of thread context so free using
@@ -194,11 +188,6 @@ HttpOpRequest::~HttpOpRequest()
mReplyBody = NULL;
}
- if (mReplyHeaders)
- {
- mReplyHeaders->release();
- mReplyHeaders = NULL;
- }
}
@@ -299,7 +288,7 @@ HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id,
HttpRequest::priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers)
+ HttpHeaders::ptr_t &headers)
{
setupCommon(policy_id, priority, url, NULL, options, headers);
mReqMethod = HOR_GET;
@@ -314,7 +303,7 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id,
size_t offset,
size_t len,
HttpOptions * options,
- HttpHeaders * headers)
+ HttpHeaders::ptr_t &headers)
{
setupCommon(policy_id, priority, url, NULL, options, headers);
mReqMethod = HOR_GET;
@@ -334,7 +323,7 @@ HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers)
+ HttpHeaders::ptr_t &headers)
{
setupCommon(policy_id, priority, url, body, options, headers);
mReqMethod = HOR_POST;
@@ -348,7 +337,7 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers)
+ HttpHeaders::ptr_t &headers)
{
setupCommon(policy_id, priority, url, body, options, headers);
mReqMethod = HOR_PUT;
@@ -361,7 +350,7 @@ HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id,
HttpRequest::priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers)
+ HttpHeaders::ptr_t &headers)
{
setupCommon(policy_id, priority, url, NULL, options, headers);
mReqMethod = HOR_DELETE;
@@ -375,7 +364,7 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers)
+ HttpHeaders::ptr_t &headers)
{
setupCommon(policy_id, priority, url, body, options, headers);
mReqMethod = HOR_PATCH;
@@ -388,7 +377,7 @@ HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id,
HttpRequest::priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers)
+ HttpHeaders::ptr_t &headers)
{
setupCommon(policy_id, priority, url, NULL, options, headers);
mReqMethod = HOR_COPY;
@@ -402,7 +391,7 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers)
+ HttpHeaders::ptr_t &headers)
{
mProcFlags = 0U;
mReqPolicy = policy_id;
@@ -415,7 +404,7 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id,
}
if (headers && ! mReqHeaders)
{
- headers->addRef();
+ //headers->addRef();
mReqHeaders = headers;
}
if (options && ! mReqOptions)
@@ -467,11 +456,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
mReplyOffset = 0;
mReplyLength = 0;
mReplyFullLength = 0;
- if (mReplyHeaders)
- {
- mReplyHeaders->release();
- mReplyHeaders = NULL;
- }
+ mReplyHeaders.reset();
mReplyConType.clear();
// *FIXME: better error handling later
@@ -946,7 +931,7 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi
// Save headers in response
if (! op->mReplyHeaders)
{
- op->mReplyHeaders = new HttpHeaders;
+ op->mReplyHeaders = HttpHeaders::ptr_t(new HttpHeaders);
}
op->mReplyHeaders->append(name, value ? value : "");
}
diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h
index b1bb101bea..0465c2b83f 100755
--- a/indra/llcorehttp/_httpoprequest.h
+++ b/indra/llcorehttp/_httpoprequest.h
@@ -41,6 +41,7 @@
#include "_httpoperation.h"
#include "_refcounted.h"
+#include "httpheaders.h"
namespace LLCore
{
@@ -105,7 +106,7 @@ public:
HttpRequest::priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers);
+ HttpHeaders::ptr_t & headers);
HttpStatus setupGetByteRange(HttpRequest::policy_t policy_id,
HttpRequest::priority_t priority,
@@ -113,40 +114,40 @@ public:
size_t offset,
size_t len,
HttpOptions * options,
- HttpHeaders * headers);
+ HttpHeaders::ptr_t & headers);
HttpStatus setupPost(HttpRequest::policy_t policy_id,
HttpRequest::priority_t priority,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers);
+ HttpHeaders::ptr_t & headers);
HttpStatus setupPut(HttpRequest::policy_t policy_id,
HttpRequest::priority_t priority,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers);
+ HttpHeaders::ptr_t & headers);
HttpStatus setupDelete(HttpRequest::policy_t policy_id,
HttpRequest::priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers);
+ HttpHeaders::ptr_t & headers);
HttpStatus setupPatch(HttpRequest::policy_t policy_id,
HttpRequest::priority_t priority,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers);
+ HttpHeaders::ptr_t & headers);
HttpStatus setupCopy(HttpRequest::policy_t policy_id,
HttpRequest::priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers);
+ HttpHeaders::ptr_t & headers);
// Internal method used to setup the libcurl options for a request.
// Does all the libcurl handle setup in one place.
@@ -167,7 +168,7 @@ protected:
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers);
+ HttpHeaders::ptr_t &headers);
// libcurl operational callbacks
//
@@ -197,7 +198,7 @@ public:
BufferArray * mReqBody;
off_t mReqOffset;
size_t mReqLength;
- HttpHeaders * mReqHeaders;
+ HttpHeaders::ptr_t mReqHeaders;
HttpOptions * mReqOptions;
// Transport data
@@ -215,7 +216,7 @@ public:
off_t mReplyOffset;
size_t mReplyLength;
size_t mReplyFullLength;
- HttpHeaders * mReplyHeaders;
+ HttpHeaders::ptr_t mReplyHeaders;
std::string mReplyConType;
int mReplyRetryAfter;
@@ -246,7 +247,7 @@ public:
// Internal function to append the contents of an HttpHeaders
// instance to a curl_slist object.
-curl_slist * append_headers_to_slist(const HttpHeaders *, curl_slist * slist);
+curl_slist * append_headers_to_slist(const HttpHeaders::ptr_t &, curl_slist * slist);
} // end namespace LLCore
diff --git a/indra/llcorehttp/httpheaders.cpp b/indra/llcorehttp/httpheaders.cpp
index e03b1b080d..f586191a7c 100755
--- a/indra/llcorehttp/httpheaders.cpp
+++ b/indra/llcorehttp/httpheaders.cpp
@@ -34,7 +34,6 @@ namespace LLCore
HttpHeaders::HttpHeaders()
- : RefCounted(true)
{}
diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h
index 8f14568fa3..a97bae5537 100755
--- a/indra/llcorehttp/httpheaders.h
+++ b/indra/llcorehttp/httpheaders.h
@@ -74,7 +74,7 @@ namespace LLCore
/// constructor is given a refcount.
///
-class HttpHeaders : public LLCoreInt::RefCounted
+class HttpHeaders: private boost::noncopyable
{
public:
typedef std::pair<std::string, std::string> header_t;
@@ -91,10 +91,11 @@ public:
/// to the instance. A call to @see release() will destroy
/// the instance.
HttpHeaders();
+ virtual ~HttpHeaders(); // Use release()
- typedef LLCoreInt::IntrusivePtr<HttpHeaders> ptr_t;
+ //typedef LLCoreInt::IntrusivePtr<HttpHeaders> ptr_t;
+ typedef boost::shared_ptr<HttpHeaders> ptr_t;
protected:
- virtual ~HttpHeaders(); // Use release()
HttpHeaders(const HttpHeaders &); // Not defined
void operator=(const HttpHeaders &); // Not defined
diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp
index d4c60a6f14..b5ea0b44b0 100755
--- a/indra/llcorehttp/httprequest.cpp
+++ b/indra/llcorehttp/httprequest.cpp
@@ -198,7 +198,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id,
priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler)
{
HttpStatus status;
@@ -232,7 +232,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id,
size_t offset,
size_t len,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler)
{
HttpStatus status;
@@ -265,7 +265,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler)
{
HttpStatus status;
@@ -298,7 +298,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler)
{
HttpStatus status;
@@ -329,7 +329,7 @@ HttpHandle HttpRequest::requestDelete(policy_t policy_id,
priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler)
{
HttpStatus status;
@@ -361,7 +361,7 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id,
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler)
{
HttpStatus status;
@@ -392,7 +392,7 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id,
priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler)
{
HttpStatus status;
diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h
index e87a8b691a..c0622372e1 100755
--- a/indra/llcorehttp/httprequest.h
+++ b/indra/llcorehttp/httprequest.h
@@ -31,6 +31,7 @@
#include "httpcommon.h"
#include "httphandler.h"
+#include "httpheaders.h"
namespace LLCore
{
@@ -349,7 +350,7 @@ public:
priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * handler);
@@ -392,7 +393,7 @@ public:
size_t offset,
size_t len,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * handler);
@@ -433,7 +434,7 @@ public:
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * handler);
@@ -474,7 +475,7 @@ public:
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * handler);
@@ -494,7 +495,7 @@ public:
priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler);
/// Queue a full HTTP PUT. Query arguments and body may
@@ -517,7 +518,7 @@ public:
const std::string & url,
BufferArray * body,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler);
/// Queue a full HTTP PUT. Query arguments and body may
@@ -536,7 +537,7 @@ public:
priority_t priority,
const std::string & url,
HttpOptions * options,
- HttpHeaders * headers,
+ HttpHeaders::ptr_t &headers,
HttpHandler * user_handler);
/// Queue a NoOp request.
diff --git a/indra/llcorehttp/httpresponse.cpp b/indra/llcorehttp/httpresponse.cpp
index 7d88f02527..f5ad2ebd47 100755
--- a/indra/llcorehttp/httpresponse.cpp
+++ b/indra/llcorehttp/httpresponse.cpp
@@ -39,7 +39,7 @@ HttpResponse::HttpResponse()
mReplyLength(0U),
mReplyFullLength(0U),
mBufferArray(NULL),
- mHeaders(NULL),
+ mHeaders(),
mRetries(0U),
m503Retries(0U),
mRequestUrl()
@@ -49,7 +49,7 @@ HttpResponse::HttpResponse()
HttpResponse::~HttpResponse()
{
setBody(NULL);
- setHeaders(NULL);
+ //setHeaders();
}
@@ -72,22 +72,9 @@ void HttpResponse::setBody(BufferArray * ba)
}
-void HttpResponse::setHeaders(HttpHeaders * headers)
+void HttpResponse::setHeaders(HttpHeaders::ptr_t &headers)
{
- if (mHeaders == headers)
- return;
-
- if (mHeaders)
- {
- mHeaders->release();
- }
-
- if (headers)
- {
- headers->addRef();
- }
-
- mHeaders = headers;
+ mHeaders = headers;
}
size_t HttpResponse::getBodySize() const
diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h
index 6c3b4da5e6..0bfa4585c7 100755
--- a/indra/llcorehttp/httpresponse.h
+++ b/indra/llcorehttp/httpresponse.h
@@ -31,7 +31,7 @@
#include <string>
#include "httpcommon.h"
-
+#include "httpheaders.h"
#include "_refcounted.h"
@@ -120,13 +120,13 @@ public:
///
/// Caller can hold onto the headers by incrementing the reference
/// count of the returned object.
- HttpHeaders * getHeaders() const
- {
+ HttpHeaders::ptr_t getHeaders() const
+ {
return mHeaders;
- }
+ }
/// Behaves like @see setResponse() but for header data.
- void setHeaders(HttpHeaders * headers);
+ void setHeaders(HttpHeaders::ptr_t &headers);
/// If a 'Range:' header was used, these methods are involved
/// in setting and returning data about the actual response.
@@ -212,7 +212,7 @@ protected:
unsigned int mReplyLength;
unsigned int mReplyFullLength;
BufferArray * mBufferArray;
- HttpHeaders * mHeaders;
+ HttpHeaders::ptr_t mHeaders;
std::string mContentType;
unsigned int mRetries;
unsigned int m503Retries;