summaryrefslogtreecommitdiff
path: root/indra/llcorehttp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcorehttp')
-rw-r--r--indra/llcorehttp/_httplibcurl.h8
-rw-r--r--indra/llcorehttp/_httpoperation.h24
-rw-r--r--indra/llcorehttp/_httpoprequest.cpp23
-rw-r--r--indra/llcorehttp/_httpoprequest.h4
-rw-r--r--indra/llcorehttp/_httpopsetget.h4
-rw-r--r--indra/llcorehttp/_httppolicy.h4
-rw-r--r--indra/llcorehttp/_httppolicyclass.h2
-rw-r--r--indra/llcorehttp/_httppolicyglobal.h2
-rw-r--r--indra/llcorehttp/_httpreadyqueue.h4
-rw-r--r--indra/llcorehttp/_httpreplyqueue.h7
-rw-r--r--indra/llcorehttp/_httprequestqueue.h4
-rw-r--r--indra/llcorehttp/_httpservice.cpp1
-rw-r--r--indra/llcorehttp/_httpservice.h4
-rw-r--r--indra/llcorehttp/_refcounted.h8
-rw-r--r--indra/llcorehttp/_thread.h6
-rw-r--r--indra/llcorehttp/bufferarray.cpp6
-rw-r--r--indra/llcorehttp/bufferarray.h4
-rw-r--r--indra/llcorehttp/bufferstream.h4
-rw-r--r--indra/llcorehttp/examples/http_texture_load.cpp52
-rw-r--r--indra/llcorehttp/httpcommon.cpp2
-rw-r--r--indra/llcorehttp/httpcommon.h15
-rw-r--r--indra/llcorehttp/httpheaders.h10
-rw-r--r--indra/llcorehttp/httpoptions.cpp6
-rw-r--r--indra/llcorehttp/httpoptions.h17
-rw-r--r--indra/llcorehttp/httprequest.cpp30
-rw-r--r--indra/llcorehttp/httprequest.h8
-rw-r--r--indra/llcorehttp/httpresponse.h4
-rwxr-xr-xindra/llcorehttp/llhttpconstants.cpp2
-rwxr-xr-xindra/llcorehttp/llhttpconstants.h2
-rwxr-xr-xindra/llcorehttp/tests/llcorehttp_test.cpp57
-rw-r--r--indra/llcorehttp/tests/test_httprequest.hpp13
-rw-r--r--indra/llcorehttp/tests/test_refcounted.hpp3
32 files changed, 134 insertions, 206 deletions
diff --git a/indra/llcorehttp/_httplibcurl.h b/indra/llcorehttp/_httplibcurl.h
index 3631965837..58affcb796 100644
--- a/indra/llcorehttp/_httplibcurl.h
+++ b/indra/llcorehttp/_httplibcurl.h
@@ -61,8 +61,8 @@ public:
virtual ~HttpLibcurl();
private:
- HttpLibcurl(const HttpLibcurl &); // Not defined
- void operator=(const HttpLibcurl &); // Not defined
+ HttpLibcurl(const HttpLibcurl&) = delete;
+ void operator=(const HttpLibcurl&) = delete;
public:
typedef std::shared_ptr<HttpOpRequest> opReqPtr_t;
@@ -179,8 +179,8 @@ protected:
~HandleCache();
private:
- HandleCache(const HandleCache &); // Not defined
- void operator=(const HandleCache &); // Not defined
+ HandleCache(const HandleCache&) = delete;
+ void operator=(const HandleCache&) = delete;
public:
/// Allocate a curl handle for caller. May be freed using
diff --git a/indra/llcorehttp/_httpoperation.h b/indra/llcorehttp/_httpoperation.h
index ff7efe60e9..8412043aa5 100644
--- a/indra/llcorehttp/_httpoperation.h
+++ b/indra/llcorehttp/_httpoperation.h
@@ -68,8 +68,7 @@ class HttpService;
/// via queue-like interfaces that are thread compatible
/// and those interfaces establish the access rules.
-class HttpOperation : private boost::noncopyable,
- public std::enable_shared_from_this<HttpOperation>
+class HttpOperation : public std::enable_shared_from_this<HttpOperation>
{
public:
typedef std::shared_ptr<HttpOperation> ptr_t;
@@ -82,6 +81,9 @@ public:
/// Threading: called by any thread.
virtual ~HttpOperation(); // Use release()
+ // Non-copyable
+ HttpOperation(const HttpOperation&) = delete;
+ HttpOperation& operator=(const HttpOperation&) = delete;
public:
/// Register a reply queue and a handler for completion notifications.
@@ -220,12 +222,10 @@ class HttpOpStop : public HttpOperation
{
public:
HttpOpStop();
-
virtual ~HttpOpStop();
-private:
- HttpOpStop(const HttpOpStop &); // Not defined
- void operator=(const HttpOpStop &); // Not defined
+ HttpOpStop(const HttpOpStop &) = delete;
+ HttpOpStop& operator=(const HttpOpStop&) = delete;
public:
virtual void stageFromRequest(HttpService *);
@@ -242,12 +242,10 @@ class HttpOpNull : public HttpOperation
{
public:
HttpOpNull();
-
virtual ~HttpOpNull();
-private:
- HttpOpNull(const HttpOpNull &); // Not defined
- void operator=(const HttpOpNull &); // Not defined
+ HttpOpNull(const HttpOpNull&) = delete;
+ HttpOpNull& operator=(const HttpOpNull&) = delete;
public:
virtual void stageFromRequest(HttpService *);
@@ -264,12 +262,10 @@ public:
// 0 does a hard spin in the operation
// 1 does a soft spin continuously requeuing itself
HttpOpSpin(int mode);
-
virtual ~HttpOpSpin();
-private:
- HttpOpSpin(const HttpOpSpin &); // Not defined
- void operator=(const HttpOpSpin &); // Not defined
+ HttpOpSpin(const HttpOpSpin&) = delete;
+ HttpOpSpin& operator=(const HttpOpSpin&) = delete;
public:
virtual void stageFromRequest(HttpService *);
diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp
index 6186e7a308..bbf39c2afa 100644
--- a/indra/llcorehttp/_httpoprequest.cpp
+++ b/indra/llcorehttp/_httpoprequest.cpp
@@ -153,7 +153,7 @@ HttpOpRequest::HttpOpRequest()
mPolicyRetryLimit(HTTP_RETRY_COUNT_DEFAULT),
mPolicyMinRetryBackoff(HttpTime(HTTP_RETRY_BACKOFF_MIN_DEFAULT)),
mPolicyMaxRetryBackoff(HttpTime(HTTP_RETRY_BACKOFF_MAX_DEFAULT)),
- mCallbackSSLVerify(NULL)
+ mCallbackSSLVerify(nullptr)
{
// *NOTE: As members are added, retry initialization/cleanup
// may need to be extended in @see prepareRequest().
@@ -272,7 +272,7 @@ void HttpOpRequest::visitNotifier(HttpRequest * request)
response->setContentType(mReplyConType);
response->setRetries(mPolicyRetries, mPolicy503Retries);
- HttpResponse::TransferStats::ptr_t stats = HttpResponse::TransferStats::ptr_t(new HttpResponse::TransferStats);
+ HttpResponse::TransferStats::ptr_t stats = std::make_shared<HttpResponse::TransferStats>();
curl_easy_getinfo(mCurlHandle, CURLINFO_SIZE_DOWNLOAD, &stats->mSizeDownload);
curl_easy_getinfo(mCurlHandle, CURLINFO_TOTAL_TIME, &stats->mTotalTime);
@@ -513,7 +513,9 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
check_curl_easy_setopt(mCurlHandle, CURLOPT_NOPROGRESS, 1);
check_curl_easy_setopt(mCurlHandle, CURLOPT_URL, mReqURL.c_str());
check_curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, getHandle());
+#if LIBCURL_VERSION_MAJOR < 8
check_curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, "");
+#endif
check_curl_easy_setopt(mCurlHandle, CURLOPT_AUTOREFERER, 1);
check_curl_easy_setopt(mCurlHandle, CURLOPT_MAXREDIRS, HTTP_REDIRECTS_DEFAULT);
@@ -538,6 +540,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
long sslHostV(0L);
long dnsCacheTimeout(-1L);
long nobody(0L);
+ curl_off_t lastModified(0L);
if (mReqOptions)
{
@@ -546,6 +549,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
sslHostV = mReqOptions->getSSLVerifyHost() ? 2L : 0L;
dnsCacheTimeout = mReqOptions->getDNSCacheTimeout();
nobody = mReqOptions->getHeadersOnly() ? 1L : 0L;
+ lastModified = (curl_off_t)mReqOptions->getLastModified();
}
check_curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, follow_redirect);
@@ -554,6 +558,17 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
check_curl_easy_setopt(mCurlHandle, CURLOPT_NOBODY, nobody);
+ if (lastModified)
+ {
+ check_curl_easy_setopt(mCurlHandle, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
+#if (LIBCURL_VERSION_NUM >= 0x073B00)
+ // requires curl 7.59.0
+ check_curl_easy_setopt(mCurlHandle, CURLOPT_TIMEVALUE_LARGE, lastModified);
+#else
+ check_curl_easy_setopt(mCurlHandle, CURLOPT_TIMEVALUE, (long)lastModified);
+#endif
+ }
+
// The Linksys WRT54G V5 router has an issue with frequent
// DNS lookups from LAN machines. If they happen too often,
// like for every HTTP request, the router gets annoyed after
@@ -603,7 +618,9 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service)
case HOR_POST:
{
check_curl_easy_setopt(mCurlHandle, CURLOPT_POST, 1);
+#if LIBCURL_VERSION_MAJOR < 8
check_curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, "");
+#endif
long data_size(0);
if (mReqBody)
{
@@ -951,7 +968,7 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi
// Save headers in response
if (! op->mReplyHeaders)
{
- op->mReplyHeaders = HttpHeaders::ptr_t(new HttpHeaders);
+ op->mReplyHeaders = std::make_shared<HttpHeaders>();
}
op->mReplyHeaders->append(name, value ? value : "");
}
diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h
index b029bc740c..717535555c 100644
--- a/indra/llcorehttp/_httpoprequest.h
+++ b/indra/llcorehttp/_httpoprequest.h
@@ -73,8 +73,8 @@ public:
virtual ~HttpOpRequest(); // Use release()
private:
- HttpOpRequest(const HttpOpRequest &); // Not defined
- void operator=(const HttpOpRequest &); // Not defined
+ HttpOpRequest(const HttpOpRequest&) = delete;
+ void operator=(const HttpOpRequest&) = delete;
public:
enum EMethod
diff --git a/indra/llcorehttp/_httpopsetget.h b/indra/llcorehttp/_httpopsetget.h
index 0b927a6b71..ff8204547b 100644
--- a/indra/llcorehttp/_httpopsetget.h
+++ b/indra/llcorehttp/_httpopsetget.h
@@ -60,8 +60,8 @@ public:
virtual ~HttpOpSetGet(); // Use release()
private:
- HttpOpSetGet(const HttpOpSetGet &); // Not defined
- void operator=(const HttpOpSetGet &); // Not defined
+ HttpOpSetGet(const HttpOpSetGet&) = delete;
+ void operator=(const HttpOpSetGet&) = delete;
public:
/// Threading: called by application thread
diff --git a/indra/llcorehttp/_httppolicy.h b/indra/llcorehttp/_httppolicy.h
index a074949f20..82f552176e 100644
--- a/indra/llcorehttp/_httppolicy.h
+++ b/indra/llcorehttp/_httppolicy.h
@@ -56,8 +56,8 @@ public:
virtual ~HttpPolicy();
private:
- HttpPolicy(const HttpPolicy &); // Not defined
- void operator=(const HttpPolicy &); // Not defined
+ HttpPolicy(const HttpPolicy&) = delete;
+ void operator=(const HttpPolicy&) = delete;
public:
typedef std::shared_ptr<HttpOpRequest> opReqPtr_t;
diff --git a/indra/llcorehttp/_httppolicyclass.h b/indra/llcorehttp/_httppolicyclass.h
index 32bcad4f9c..5bf0fa1fa7 100644
--- a/indra/llcorehttp/_httppolicyclass.h
+++ b/indra/llcorehttp/_httppolicyclass.h
@@ -53,7 +53,7 @@ public:
~HttpPolicyClass();
HttpPolicyClass & operator=(const HttpPolicyClass &);
- HttpPolicyClass(const HttpPolicyClass &); // Not defined
+ HttpPolicyClass(const HttpPolicyClass &);
public:
HttpStatus set(HttpRequest::EPolicyOption opt, long value);
diff --git a/indra/llcorehttp/_httppolicyglobal.h b/indra/llcorehttp/_httppolicyglobal.h
index d9114d167f..3840d66b22 100644
--- a/indra/llcorehttp/_httppolicyglobal.h
+++ b/indra/llcorehttp/_httppolicyglobal.h
@@ -55,7 +55,7 @@ public:
HttpPolicyGlobal & operator=(const HttpPolicyGlobal &);
private:
- HttpPolicyGlobal(const HttpPolicyGlobal &); // Not defined
+ HttpPolicyGlobal(const HttpPolicyGlobal &) = delete;
public:
HttpStatus set(HttpRequest::EPolicyOption opt, long value);
diff --git a/indra/llcorehttp/_httpreadyqueue.h b/indra/llcorehttp/_httpreadyqueue.h
index 0bc0723511..04fcf25356 100644
--- a/indra/llcorehttp/_httpreadyqueue.h
+++ b/indra/llcorehttp/_httpreadyqueue.h
@@ -77,8 +77,8 @@ public:
{}
protected:
- HttpReadyQueue(const HttpReadyQueue &); // Not defined
- void operator=(const HttpReadyQueue &); // Not defined
+ HttpReadyQueue(const HttpReadyQueue&) = delete;
+ void operator=(const HttpReadyQueue&) = delete;
public:
diff --git a/indra/llcorehttp/_httpreplyqueue.h b/indra/llcorehttp/_httpreplyqueue.h
index d8847fafb5..e1b5648691 100644
--- a/indra/llcorehttp/_httpreplyqueue.h
+++ b/indra/llcorehttp/_httpreplyqueue.h
@@ -30,8 +30,6 @@
#include "_refcounted.h"
#include "_mutex.h"
-#include "boost/noncopyable.hpp"
-
namespace LLCore
{
@@ -59,7 +57,7 @@ class HttpOperation;
/// will be coded anyway so it shouldn't be too much of a
/// burden.
-class HttpReplyQueue : private boost::noncopyable
+class HttpReplyQueue
{
public:
@@ -69,6 +67,9 @@ public:
HttpReplyQueue();
virtual ~HttpReplyQueue();
+ HttpReplyQueue(const HttpReplyQueue&) = delete;
+ HttpReplyQueue& operator=(const HttpReplyQueue&) = delete;
+
public:
typedef std::vector< opPtr_t > OpContainer;
diff --git a/indra/llcorehttp/_httprequestqueue.h b/indra/llcorehttp/_httprequestqueue.h
index 0823126f78..82537c9053 100644
--- a/indra/llcorehttp/_httprequestqueue.h
+++ b/indra/llcorehttp/_httprequestqueue.h
@@ -57,8 +57,8 @@ protected:
virtual ~HttpRequestQueue(); // Use release()
private:
- HttpRequestQueue(const HttpRequestQueue &); // Not defined
- void operator=(const HttpRequestQueue &); // Not defined
+ HttpRequestQueue(const HttpRequestQueue&) = delete;
+ void operator=(const HttpRequestQueue&) = delete;
public:
typedef std::shared_ptr<HttpOperation> opPtr_t;
diff --git a/indra/llcorehttp/_httpservice.cpp b/indra/llcorehttp/_httpservice.cpp
index 5880fb7e87..a8660decc3 100644
--- a/indra/llcorehttp/_httpservice.cpp
+++ b/indra/llcorehttp/_httpservice.cpp
@@ -27,7 +27,6 @@
#include "_httpservice.h"
#include <boost/bind.hpp>
-#include <boost/function.hpp>
#include "_httpoperation.h"
#include "_httprequestqueue.h"
diff --git a/indra/llcorehttp/_httpservice.h b/indra/llcorehttp/_httpservice.h
index 13eb034f0e..7202b496fc 100644
--- a/indra/llcorehttp/_httpservice.h
+++ b/indra/llcorehttp/_httpservice.h
@@ -86,8 +86,8 @@ protected:
virtual ~HttpService();
private:
- HttpService(const HttpService &); // Not defined
- void operator=(const HttpService &); // Not defined
+ HttpService(const HttpService&) = delete;
+ void operator=(const HttpService&) = delete;
public:
enum EState
diff --git a/indra/llcorehttp/_refcounted.h b/indra/llcorehttp/_refcounted.h
index 7470965a7f..63684b5e2c 100644
--- a/indra/llcorehttp/_refcounted.h
+++ b/indra/llcorehttp/_refcounted.h
@@ -31,12 +31,9 @@
#include "linden_common.h"
#include "fix_macros.h"
-#include <boost/thread.hpp>
#include <boost/intrusive_ptr.hpp>
-
#include "llatomic.h"
-
namespace LLCoreInt
{
@@ -44,8 +41,9 @@ namespace LLCoreInt
class RefCounted
{
private:
- RefCounted(); // Not defined - may not be default constructed
- void operator=(const RefCounted &); // Not defined
+ RefCounted() = delete; // may not be default constructed
+ RefCounted(const RefCounted&) = delete;
+ RefCounted& operator=(const RefCounted&) = delete;
public:
explicit RefCounted(bool const implicit)
diff --git a/indra/llcorehttp/_thread.h b/indra/llcorehttp/_thread.h
index 6c0e39cf92..93efbbedbc 100644
--- a/indra/llcorehttp/_thread.h
+++ b/indra/llcorehttp/_thread.h
@@ -42,8 +42,10 @@ namespace LLCoreInt
class HttpThread : public RefCounted
{
private:
- HttpThread(); // Not defined
- void operator=(const HttpThread &); // Not defined
+ // May not be default constructed or copied
+ HttpThread() = delete;
+ HttpThread(const HttpThread&) = delete;
+ void operator=(const HttpThread &) = delete;
void at_exit()
{
diff --git a/indra/llcorehttp/bufferarray.cpp b/indra/llcorehttp/bufferarray.cpp
index 6b33661d8f..46c03f991d 100644
--- a/indra/llcorehttp/bufferarray.cpp
+++ b/indra/llcorehttp/bufferarray.cpp
@@ -57,12 +57,12 @@ public:
void operator delete(void *);
void operator delete(void *, size_t len);
+ Block(const Block&) = delete;
+ Block& operator=(const Block&) = delete;
+
protected:
Block(size_t len);
- Block(const Block &); // Not defined
- void operator=(const Block &); // Not defined
-
// Allocate the block with the additional space for the
// buffered data at the end of the object.
void * operator new(size_t len, size_t addl_len);
diff --git a/indra/llcorehttp/bufferarray.h b/indra/llcorehttp/bufferarray.h
index 5105dbc4f7..9abe1778ed 100644
--- a/indra/llcorehttp/bufferarray.h
+++ b/indra/llcorehttp/bufferarray.h
@@ -79,8 +79,8 @@ protected:
virtual ~BufferArray(); // Use release()
private:
- BufferArray(const BufferArray &); // Not defined
- void operator=(const BufferArray &); // Not defined
+ BufferArray(const BufferArray&) = delete;
+ void operator=(const BufferArray&) = delete;
public:
// Internal magic number, may be used by unit tests.
diff --git a/indra/llcorehttp/bufferstream.h b/indra/llcorehttp/bufferstream.h
index 93891810aa..ba84821df3 100644
--- a/indra/llcorehttp/bufferstream.h
+++ b/indra/llcorehttp/bufferstream.h
@@ -91,8 +91,8 @@ public:
virtual ~BufferArrayStreamBuf();
private:
- BufferArrayStreamBuf(const BufferArrayStreamBuf &); // Not defined
- void operator=(const BufferArrayStreamBuf &); // Not defined
+ BufferArrayStreamBuf(const BufferArrayStreamBuf&) = delete;
+ void operator=(const BufferArrayStreamBuf&) = delete;
public:
// Input interfaces from std::streambuf
diff --git a/indra/llcorehttp/examples/http_texture_load.cpp b/indra/llcorehttp/examples/http_texture_load.cpp
index 72e0c29a24..986e675d00 100644
--- a/indra/llcorehttp/examples/http_texture_load.cpp
+++ b/indra/llcorehttp/examples/http_texture_load.cpp
@@ -52,8 +52,6 @@
void init_curl();
void term_curl();
-void ssl_thread_id_callback(CRYPTO_THREADID*);
-void ssl_locking_callback(int mode, int type, const char * file, int line);
void usage(std::ostream & out);
// Default command line settings
@@ -606,63 +604,15 @@ void WorkingSet::loadAssetUuids(FILE * in)
}
-int ssl_mutex_count(0);
-LLCoreInt::HttpMutex ** ssl_mutex_list = NULL;
-
void init_curl()
{
curl_global_init(CURL_GLOBAL_ALL);
-
- ssl_mutex_count = CRYPTO_num_locks();
- if (ssl_mutex_count > 0)
- {
- ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
-
- for (int i(0); i < ssl_mutex_count; ++i)
- {
- ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
- }
-
- CRYPTO_set_locking_callback(ssl_locking_callback);
- CRYPTO_THREADID_set_callback(ssl_thread_id_callback);
- }
}
void term_curl()
{
- CRYPTO_set_locking_callback(NULL);
- for (int i(0); i < ssl_mutex_count; ++i)
- {
- delete ssl_mutex_list[i];
- }
- delete [] ssl_mutex_list;
-}
-
-
-void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid)
-{
-#if defined(WIN32)
- CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread());
-#else
- CRYPTO_THREADID_set_pointer(pthreadid, pthread_self());
-#endif
-}
-
-
-void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */)
-{
- if (type >= 0 && type < ssl_mutex_count)
- {
- if (mode & CRYPTO_LOCK)
- {
- ssl_mutex_list[type]->lock();
- }
- else
- {
- ssl_mutex_list[type]->unlock();
- }
- }
+ curl_global_cleanup();
}
diff --git a/indra/llcorehttp/httpcommon.cpp b/indra/llcorehttp/httpcommon.cpp
index 315ff15ebb..2b09653d8e 100644
--- a/indra/llcorehttp/httpcommon.cpp
+++ b/indra/llcorehttp/httpcommon.cpp
@@ -289,8 +289,10 @@ CURL *getCurlTemplateHandle()
check_curl_code(result, CURLOPT_NOSIGNAL);
result = curl_easy_setopt(curlpTemplateHandle, CURLOPT_NOPROGRESS, 1);
check_curl_code(result, CURLOPT_NOPROGRESS);
+#if LIBCURL_VERSION_MAJOR < 8
result = curl_easy_setopt(curlpTemplateHandle, CURLOPT_ENCODING, "");
check_curl_code(result, CURLOPT_ENCODING);
+#endif
result = curl_easy_setopt(curlpTemplateHandle, CURLOPT_AUTOREFERER, 1);
check_curl_code(result, CURLOPT_AUTOREFERER);
result = curl_easy_setopt(curlpTemplateHandle, CURLOPT_FOLLOWLOCATION, 1);
diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h
index 511a17e000..1c003a0966 100644
--- a/indra/llcorehttp/httpcommon.h
+++ b/indra/llcorehttp/httpcommon.h
@@ -191,7 +191,6 @@
#include "llsd.h"
#include <string>
#include <curl/curl.h>
-#include "boost/noncopyable.hpp"
namespace LLCore
{
@@ -297,25 +296,25 @@ struct HttpStatus
HttpStatus()
{
- mDetails = std::shared_ptr<Details>(new Details(LLCORE, HE_SUCCESS));
+ mDetails = std::make_shared<Details>(LLCORE, HE_SUCCESS);
}
HttpStatus(type_enum_t type, short status)
{
- mDetails = std::shared_ptr<Details>(new Details(type, status));
+ mDetails = std::make_shared<Details>(type, status);
}
HttpStatus(int http_status)
{
- mDetails = std::shared_ptr<Details>(new Details(http_status,
- (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR));
+ mDetails = std::make_shared<Details>(http_status,
+ (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR);
llassert(http_status >= 100 && http_status <= 999);
}
HttpStatus(int http_status, const std::string &message)
{
- mDetails = std::shared_ptr<Details>(new Details(http_status,
- (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR));
+ mDetails = std::make_shared<Details>(http_status,
+ (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR);
llassert(http_status >= 100 && http_status <= 999);
mDetails->mMessage = message;
}
@@ -337,7 +336,7 @@ struct HttpStatus
HttpStatus & clone(const HttpStatus &rhs)
{
- mDetails = std::shared_ptr<Details>(new Details(*rhs.mDetails));
+ mDetails = std::make_shared<Details>(*rhs.mDetails);
return *this;
}
diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h
index a5ca7749b0..6a03cf4083 100644
--- a/indra/llcorehttp/httpheaders.h
+++ b/indra/llcorehttp/httpheaders.h
@@ -74,7 +74,7 @@ namespace LLCore
/// constructor is given a refcount.
///
-class HttpHeaders: private boost::noncopyable
+class HttpHeaders
{
public:
typedef std::pair<std::string, std::string> header_t;
@@ -94,11 +94,11 @@ public:
HttpHeaders();
virtual ~HttpHeaders(); // Use release()
- //typedef LLCoreInt::IntrusivePtr<HttpHeaders> ptr_t;
-protected:
+ // Non-copyable
+ HttpHeaders(const HttpHeaders&) = delete;
+ HttpHeaders& operator=(const HttpHeaders&) = delete;
- HttpHeaders(const HttpHeaders &); // Not defined
- void operator=(const HttpHeaders &); // Not defined
+ //typedef LLCoreInt::IntrusivePtr<HttpHeaders> ptr_t;
public:
// Empty the list of headers.
diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp
index d85f6039b1..5abd28e211 100644
--- a/indra/llcorehttp/httpoptions.cpp
+++ b/indra/llcorehttp/httpoptions.cpp
@@ -47,6 +47,7 @@ HttpOptions::HttpOptions() :
mVerifyPeer(sDefaultVerifyPeer),
mVerifyHost(false),
mDNSCacheTimeout(-1L),
+ mLastModified(0),
mNoBody(false)
{}
@@ -129,6 +130,11 @@ void HttpOptions::setHeadersOnly(bool nobody)
}
}
+void HttpOptions::setLastModified(time_t lastModified)
+{
+ mLastModified = lastModified;
+}
+
void HttpOptions::setDefaultSSLVerifyPeer(bool verify)
{
sDefaultVerifyPeer = verify;
diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h
index 56a28013cb..d50c5470ae 100644
--- a/indra/llcorehttp/httpoptions.h
+++ b/indra/llcorehttp/httpoptions.h
@@ -55,7 +55,7 @@ namespace LLCore
/// Allocation: Refcounted, heap only. Caller of the constructor
/// is given a refcount.
///
-class HttpOptions : private boost::noncopyable
+class HttpOptions
{
public:
HttpOptions();
@@ -64,10 +64,9 @@ public:
virtual ~HttpOptions(); // Use release()
-protected:
-
- HttpOptions(const HttpOptions &); // Not defined
- void operator=(const HttpOptions &); // Not defined
+ // Non-copyable
+ HttpOptions(const HttpOptions&) = delete;
+ HttpOptions& operator=(const HttpOptions&) = delete;
public:
@@ -178,6 +177,13 @@ public:
return mNoBody;
}
+ // Default: 0
+ void setLastModified(time_t lastModified);
+ time_t getLastModified() const
+ {
+ return mLastModified;
+ }
+
/// Sets default behavior for verifying that the name in the
/// security certificate matches the name of the host contacted.
/// Defaults false if not set, but should be set according to
@@ -199,6 +205,7 @@ protected:
bool mVerifyHost;
int mDNSCacheTimeout;
bool mNoBody;
+ time_t mLastModified;
static bool sDefaultVerifyPeer;
}; // end class HttpOptions
diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp
index 2aaf71f8a4..d8fcd6a03f 100644
--- a/indra/llcorehttp/httprequest.cpp
+++ b/indra/llcorehttp/httprequest.cpp
@@ -60,7 +60,7 @@ HttpRequest::HttpRequest()
mRequestQueue = HttpRequestQueue::instanceOf();
mRequestQueue->addRef();
- mReplyQueue.reset( new HttpReplyQueue() );
+ mReplyQueue = std::make_shared<HttpReplyQueue>();
HTTPStats::instance().recordHTTPRequest();
}
@@ -129,7 +129,7 @@ HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass,
{
HttpStatus status;
- HttpOpSetGet::ptr_t op(new HttpOpSetGet());
+ HttpOpSetGet::ptr_t op = std::make_shared<HttpOpSetGet>();
if (! (status = op->setupSet(opt, pclass, value)))
{
mLastReqStatus = status;
@@ -152,7 +152,7 @@ HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass,
{
HttpStatus status;
- HttpOpSetGet::ptr_t op (new HttpOpSetGet());
+ HttpOpSetGet::ptr_t op = std::make_shared<HttpOpSetGet>();
if (! (status = op->setupSet(opt, pclass, value)))
{
mLastReqStatus = status;
@@ -190,7 +190,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id,
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
HttpStatus status;
- HttpOpRequest::ptr_t op(new HttpOpRequest());
+ HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
if (! (status = op->setupGet(policy_id, url, options, headers)))
{
mLastReqStatus = status;
@@ -219,7 +219,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id,
LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK;
HttpStatus status;
- HttpOpRequest::ptr_t op(new HttpOpRequest());
+ HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
if (! (status = op->setupGetByteRange(policy_id, url, offset, len, options, headers)))
{
mLastReqStatus = status;
@@ -246,7 +246,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id,
{
HttpStatus status;
- HttpOpRequest::ptr_t op(new HttpOpRequest());
+ HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
if (! (status = op->setupPost(policy_id, url, body, options, headers)))
{
mLastReqStatus = status;
@@ -273,7 +273,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id,
{
HttpStatus status;
- HttpOpRequest::ptr_t op (new HttpOpRequest());
+ HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
if (! (status = op->setupPut(policy_id, url, body, options, headers)))
{
mLastReqStatus = status;
@@ -298,7 +298,7 @@ HttpHandle HttpRequest::requestDelete(policy_t policy_id,
{
HttpStatus status;
- HttpOpRequest::ptr_t op(new HttpOpRequest());
+ HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
if (!(status = op->setupDelete(policy_id, url, options, headers)))
{
mLastReqStatus = status;
@@ -324,7 +324,7 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id,
{
HttpStatus status;
- HttpOpRequest::ptr_t op (new HttpOpRequest());
+ HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
if (!(status = op->setupPatch(policy_id, url, body, options, headers)))
{
mLastReqStatus = status;
@@ -349,7 +349,7 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id,
{
HttpStatus status;
- HttpOpRequest::ptr_t op(new HttpOpRequest());
+ HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
if (!(status = op->setupCopy(policy_id, url, options, headers)))
{
mLastReqStatus = status;
@@ -375,7 +375,7 @@ HttpHandle HttpRequest::requestMove(policy_t policy_id,
{
HttpStatus status;
- HttpOpRequest::ptr_t op (new HttpOpRequest());
+ HttpOpRequest::ptr_t op = std::make_shared<HttpOpRequest>();
if (!(status = op->setupMove(policy_id, url, options, headers)))
{
mLastReqStatus = status;
@@ -397,7 +397,7 @@ HttpHandle HttpRequest::requestNoOp(HttpHandler::ptr_t user_handler)
{
HttpStatus status;
- HttpOperation::ptr_t op (new HttpOpNull());
+ HttpOperation::ptr_t op = std::make_shared<HttpOpNull>();
op->setReplyPath(mReplyQueue, user_handler);
if (! (status = mRequestQueue->addOp(op))) // transfers refcount
{
@@ -463,7 +463,7 @@ HttpHandle HttpRequest::requestCancel(HttpHandle request, HttpHandler::ptr_t use
{
HttpStatus status;
- HttpOperation::ptr_t op(new HttpOpCancel(request));
+ HttpOperation::ptr_t op = std::make_shared<HttpOpCancel>(request);
op->setReplyPath(mReplyQueue, user_handler);
if (! (status = mRequestQueue->addOp(op))) // transfers refcount
{
@@ -528,7 +528,7 @@ HttpHandle HttpRequest::requestStopThread(HttpHandler::ptr_t user_handler)
HttpStatus status;
HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID);
- HttpOperation::ptr_t op(new HttpOpStop());
+ HttpOperation::ptr_t op = std::make_shared<HttpOpStop>();
op->setReplyPath(mReplyQueue, user_handler);
if (! (status = mRequestQueue->addOp(op))) // transfers refcount
{
@@ -548,7 +548,7 @@ HttpHandle HttpRequest::requestSpin(int mode)
HttpStatus status;
HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID);
- HttpOperation::ptr_t op(new HttpOpSpin(mode));
+ HttpOperation::ptr_t op = std::make_shared<HttpOpSpin>(mode);
op->setReplyPath(mReplyQueue, HttpHandler::ptr_t());
if (! (status = mRequestQueue->addOp(op))) // transfers refcount
{
diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h
index e6e051410e..f7516f127a 100644
--- a/indra/llcorehttp/httprequest.h
+++ b/indra/llcorehttp/httprequest.h
@@ -104,9 +104,9 @@ public:
/// Represents a default, catch-all policy class that guarantees
/// eventual service for any HTTP request.
- static const policy_t DEFAULT_POLICY_ID = 0;
- static const policy_t INVALID_POLICY_ID = 0xFFFFFFFFU;
- static const policy_t GLOBAL_POLICY_ID = 0xFFFFFFFEU;
+ static constexpr policy_t DEFAULT_POLICY_ID = 0;
+ static constexpr policy_t INVALID_POLICY_ID = 0xFFFFFFFFU;
+ static constexpr policy_t GLOBAL_POLICY_ID = 0xFFFFFFFEU;
/// Create a new policy class into which requests can be made.
///
@@ -237,7 +237,7 @@ public:
/// Prototype for policy based callbacks. The callback methods will be executed
/// on the worker thread so no modifications should be made to the HttpHandler object.
- typedef boost::function<HttpStatus(const std::string &, const HttpHandler::ptr_t &, void *)> policyCallback_t;
+ typedef std::function<HttpStatus(const std::string &, const HttpHandler::ptr_t &, void *)> policyCallback_t;
/// Set a policy option for a global or class parameter at
/// startup time (prior to thread start).
diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h
index 99c8f1d2f9..ed2d76c10f 100644
--- a/indra/llcorehttp/httpresponse.h
+++ b/indra/llcorehttp/httpresponse.h
@@ -65,8 +65,8 @@ public:
protected:
virtual ~HttpResponse(); // Use release()
- HttpResponse(const HttpResponse &); // Not defined
- void operator=(const HttpResponse &); // Not defined
+ HttpResponse(const HttpResponse&) = delete;
+ void operator=(const HttpResponse&) = delete;
public:
/// Statistics for the HTTP
diff --git a/indra/llcorehttp/llhttpconstants.cpp b/indra/llcorehttp/llhttpconstants.cpp
index 40d6c7506c..7a671543d9 100755
--- a/indra/llcorehttp/llhttpconstants.cpp
+++ b/indra/llcorehttp/llhttpconstants.cpp
@@ -100,6 +100,7 @@ const std::string HTTP_IN_HEADER_LOCATION("location");
const std::string HTTP_IN_HEADER_RETRY_AFTER("retry-after");
const std::string HTTP_IN_HEADER_SET_COOKIE("set-cookie");
const std::string HTTP_IN_HEADER_USER_AGENT("user-agent");
+const std::string HTTP_IN_HEADER_X_CONTENT_TYPE_OPTIONS("x-content-type-options");
const std::string HTTP_IN_HEADER_X_FORWARDED_FOR("x-forwarded-for");
const std::string HTTP_CONTENT_LLSD_XML("application/llsd+xml");
@@ -122,6 +123,7 @@ const std::string HTTP_CONTENT_IMAGE_BMP("image/bmp");
const std::string HTTP_NO_CACHE("no-cache");
const std::string HTTP_NO_CACHE_CONTROL("no-cache, max-age=0");
+const std::string HTTP_NOSNIFF("nosniff");
const std::string HTTP_VERB_INVALID("(invalid)");
const std::string HTTP_VERB_HEAD("HEAD");
diff --git a/indra/llcorehttp/llhttpconstants.h b/indra/llcorehttp/llhttpconstants.h
index 583f9fbcb7..71c1dfa173 100755
--- a/indra/llcorehttp/llhttpconstants.h
+++ b/indra/llcorehttp/llhttpconstants.h
@@ -190,6 +190,7 @@ extern const std::string HTTP_IN_HEADER_LOCATION;
extern const std::string HTTP_IN_HEADER_RETRY_AFTER;
extern const std::string HTTP_IN_HEADER_SET_COOKIE;
extern const std::string HTTP_IN_HEADER_USER_AGENT;
+extern const std::string HTTP_IN_HEADER_X_CONTENT_TYPE_OPTIONS;
extern const std::string HTTP_IN_HEADER_X_FORWARDED_FOR;
//// HTTP Content Types ////
@@ -215,5 +216,6 @@ extern const std::string HTTP_CONTENT_IMAGE_BMP;
//// HTTP Cache Settings ////
extern const std::string HTTP_NO_CACHE;
extern const std::string HTTP_NO_CACHE_CONTROL;
+extern const std::string HTTP_NOSNIFF;
#endif
diff --git a/indra/llcorehttp/tests/llcorehttp_test.cpp b/indra/llcorehttp/tests/llcorehttp_test.cpp
index c0cc2c8030..c7c50e6166 100755
--- a/indra/llcorehttp/tests/llcorehttp_test.cpp
+++ b/indra/llcorehttp/tests/llcorehttp_test.cpp
@@ -41,11 +41,7 @@
#include "test_httpstatus.hpp"
#include "test_refcounted.hpp"
#include "test_httpoperation.hpp"
-// As of 2019-06-28, test_httprequest.hpp consistently crashes on Mac Release
-// builds for reasons not yet diagnosed.
-#if ! (LL_DARWIN && LL_RELEASE)
#include "test_httprequest.hpp"
-#endif
#include "test_httpheaders.hpp"
#include "test_httprequestqueue.hpp"
#include "_httpservice.h"
@@ -53,9 +49,6 @@
#include "llproxy.h"
#include "llcleanup.h"
-void ssl_thread_id_callback(CRYPTO_THREADID*);
-void ssl_locking_callback(int mode, int type, const char * file, int line);
-
#if 0 // lltut provides main and runner
namespace tut
@@ -80,27 +73,10 @@ int main()
#endif // 0
-int ssl_mutex_count(0);
-LLCoreInt::HttpMutex ** ssl_mutex_list = NULL;
-
void init_curl()
{
curl_global_init(CURL_GLOBAL_ALL);
- ssl_mutex_count = CRYPTO_num_locks();
- if (ssl_mutex_count > 0)
- {
- ssl_mutex_list = new LLCoreInt::HttpMutex * [ssl_mutex_count];
-
- for (int i(0); i < ssl_mutex_count; ++i)
- {
- ssl_mutex_list[i] = new LLCoreInt::HttpMutex;
- }
-
- CRYPTO_set_locking_callback(ssl_locking_callback);
- CRYPTO_THREADID_set_callback(ssl_thread_id_callback);
- }
-
LLProxy::getInstance();
}
@@ -108,39 +84,6 @@ void init_curl()
void term_curl()
{
SUBSYSTEM_CLEANUP(LLProxy);
-
- CRYPTO_set_locking_callback(NULL);
- for (int i(0); i < ssl_mutex_count; ++i)
- {
- delete ssl_mutex_list[i];
- }
- delete [] ssl_mutex_list;
-}
-
-
-void ssl_thread_id_callback(CRYPTO_THREADID* pthreadid)
-{
-#if defined(WIN32)
- CRYPTO_THREADID_set_pointer(pthreadid, GetCurrentThread());
-#else
- CRYPTO_THREADID_set_pointer(pthreadid, pthread_self());
-#endif
-}
-
-
-void ssl_locking_callback(int mode, int type, const char * /* file */, int /* line */)
-{
- if (type >= 0 && type < ssl_mutex_count)
- {
- if (mode & CRYPTO_LOCK)
- {
- ssl_mutex_list[type]->lock();
- }
- else
- {
- ssl_mutex_list[type]->unlock();
- }
- }
}
diff --git a/indra/llcorehttp/tests/test_httprequest.hpp b/indra/llcorehttp/tests/test_httprequest.hpp
index aed906bb8f..77ed8df066 100644
--- a/indra/llcorehttp/tests/test_httprequest.hpp
+++ b/indra/llcorehttp/tests/test_httprequest.hpp
@@ -454,6 +454,10 @@ void HttpRequestTestObjectType::test<4>()
template <> template <>
void HttpRequestTestObjectType::test<5>()
{
+#ifndef LL_WINDOWS
+ skip("Skip due to issues with testing pthread cancellation");
+#endif
+
ScopedCurlInit ready;
set_test_name("HttpRequest Spin (soft) + NoOp + hard termination");
@@ -517,6 +521,9 @@ void HttpRequestTestObjectType::test<5>()
template <> template <>
void HttpRequestTestObjectType::test<6>()
{
+#ifndef LL_WINDOWS
+ skip("Skip due to issues with testing pthread cancellation");
+#endif
ScopedCurlInit ready;
set_test_name("HttpRequest Spin + NoOp + hard termination");
@@ -2779,7 +2786,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test_count; ++i)
{
char buffer[128];
- sprintf(buffer, "/bug2295/%d/", i);
+ snprintf(buffer, sizeof(buffer), "/bug2295/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
url_base + buffer,
0,
@@ -2810,7 +2817,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test2_count; ++i)
{
char buffer[128];
- sprintf(buffer, "/bug2295/00000012/%d/", i);
+ snprintf(buffer, sizeof(buffer), "/bug2295/00000012/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
url_base + buffer,
0,
@@ -2841,7 +2848,7 @@ void HttpRequestTestObjectType::test<22>()
for (int i(0); i < test3_count; ++i)
{
char buffer[128];
- sprintf(buffer, "/bug2295/inv_cont_range/%d/", i);
+ snprintf(buffer, sizeof(buffer), "/bug2295/inv_cont_range/%d/", i);
HttpHandle handle = req->requestGetByteRange(HttpRequest::DEFAULT_POLICY_ID,
url_base + buffer,
0,
diff --git a/indra/llcorehttp/tests/test_refcounted.hpp b/indra/llcorehttp/tests/test_refcounted.hpp
index c0c8e78413..eb23a25545 100644
--- a/indra/llcorehttp/tests/test_refcounted.hpp
+++ b/indra/llcorehttp/tests/test_refcounted.hpp
@@ -28,8 +28,6 @@
#include "_refcounted.h"
-// disable all of this because it's hanging win64 builds?
-#if ! (LL_WINDOWS && ADDRESS_SIZE == 64)
using namespace LLCoreInt;
namespace tut
@@ -122,5 +120,4 @@ namespace tut
ensure(rc->getRefCount() == RefCounted::NOT_REF_COUNTED);
}
}
-#endif // disabling on Win64
#endif // TEST_LLCOREINT_REF_COUNTED_H_