From 6f4d36634e980bb989b9a8b762c3c622804c43dd Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 16 Mar 2015 17:14:34 -0700 Subject: Removal of RPCXML dep on LLCurl switching to LLCore::Html --- indra/llcorehttp/httpcommon.h | 116 +++++++++++++++++++++++++++++++++--------- 1 file changed, 91 insertions(+), 25 deletions(-) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 9601f94125..0244755272 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -191,7 +191,6 @@ #include - namespace LLCore { @@ -292,35 +291,35 @@ struct HttpStatus typedef unsigned short type_enum_t; HttpStatus() - : mType(LLCORE), - mStatus(HE_SUCCESS) - {} + { + mDetails = std::unique_ptr
(new Details(LLCORE, HE_SUCCESS)); + } HttpStatus(type_enum_t type, short status) - : mType(type), - mStatus(status) - {} + { + mDetails = std::unique_ptr
(new Details(type, status)); + } HttpStatus(int http_status) - : mType(http_status), - mStatus(http_status >= 200 && http_status <= 299 - ? HE_SUCCESS - : HE_REPLY_ERROR) { + mDetails = std::unique_ptr
(new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR)); llassert(http_status >= 100 && http_status <= 999); } HttpStatus(const HttpStatus & rhs) - : mType(rhs.mType), - mStatus(rhs.mStatus) - {} + { + mDetails = std::unique_ptr
(new Details(*rhs.mDetails)); + } HttpStatus & operator=(const HttpStatus & rhs) { // Don't care if lhs & rhs are the same object + mDetails->mType = rhs.mDetails->mType; + mDetails->mStatus = rhs.mDetails->mStatus; + mDetails->mMessage = rhs.mDetails->mMessage; + mDetails->mErrorData = rhs.mDetails->mErrorData; - mType = rhs.mType; - mStatus = rhs.mStatus; return *this; } @@ -328,10 +327,6 @@ struct HttpStatus static const type_enum_t EXT_CURL_MULTI = 1; ///< mStatus is an error from a curl_multi_*() call static const type_enum_t LLCORE = 2; ///< mStatus is an HE_* error code ///< 100-999 directly represent HTTP status codes - - type_enum_t mType; - short mStatus; - /// Test for successful status in the code regardless /// of error source (internal, libcurl). /// @@ -339,7 +334,7 @@ struct HttpStatus /// operator bool() const { - return 0 == mStatus; + return 0 == mDetails->mStatus; } /// Inverse of previous operator. @@ -347,14 +342,15 @@ struct HttpStatus /// @return 'true' on any error condition bool operator !() const { - return 0 != mStatus; + return 0 != mDetails->mStatus; } /// Equality and inequality tests to bypass bool conversion /// which will do the wrong thing in conditional expressions. bool operator==(const HttpStatus & rhs) const { - return mType == rhs.mType && mStatus == rhs.mStatus; + return (mDetails->mType == rhs.mDetails->mType) && + (mDetails->mStatus == rhs.mDetails->mStatus); } bool operator!=(const HttpStatus & rhs) const @@ -395,7 +391,7 @@ struct HttpStatus /// HTTP response status (100 - 999). bool isHttpStatus() const { - return mType >= type_enum_t(100) && mType <= type_enum_t(999); + return mDetails->mType >= type_enum_t(100) && mDetails->mType <= type_enum_t(999); } /// Returns true if the status is one that will be retried @@ -403,7 +399,77 @@ struct HttpStatus /// where that logic needs to be replicated. Only applies /// to failed statuses, successful statuses will return false. bool isRetryable() const; - + + /// Returns the currently set status code as a raw number + /// + short getStatus() const + { + return mDetails->mStatus; + } + + /// Returns the currently set status type + /// + type_enum_t getType() const + { + return mDetails->mType; + } + + // TODO: There must be a better way to do this. Don't want to set these + // values here since they increase the size of a structure that is already + // being passed on the stack. Consider my options + /// Returns an optional error message if one has been set. + /// + std::string getMessage() const + { + return mDetails->mMessage; + } + + /// Sets an optional error message + /// + void setMessage(const std::string &message) + { + mDetails->mMessage = message; + } + + /// Retrieves an optionally recorded SSL certificate. + void * getErrorData() const + { + return mDetails->mErrorData; + } + + /// Optionally sets an SSL certificate on this status. + void setErrorData(void *data) + { + mDetails->mErrorData = data; + } + +private: + + struct Details + { + Details(type_enum_t type, short status): + mType(type), + mStatus(status), + mMessage(), + mErrorData(NULL) + {} + + Details(const Details &rhs) : + mType(rhs.mType), + mStatus(rhs.mStatus), + mMessage(rhs.mMessage), + mErrorData(rhs.mErrorData) + {} + + + type_enum_t mType; + short mStatus; + std::string mMessage; + void * mErrorData; + }; + + std::unique_ptr
mDetails; + }; // end struct HttpStatus } // end namespace LLCore -- cgit v1.2.3 From 379c49fc898961b52f98855c926e958df14e98c3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 13:50:07 -0700 Subject: Scratch the unique_ptr for the moment. --- indra/llcorehttp/httpcommon.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 0244755272..2aded492ea 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -188,7 +188,6 @@ /// #include "linden_common.h" // Modifies curl/curl.h interfaces - #include namespace LLCore @@ -292,24 +291,29 @@ struct HttpStatus HttpStatus() { - mDetails = std::unique_ptr
(new Details(LLCORE, HE_SUCCESS)); - } + mDetails = new Details(LLCORE, HE_SUCCESS); + } HttpStatus(type_enum_t type, short status) { - mDetails = std::unique_ptr
(new Details(type, status)); + mDetails = new Details(type, status); } HttpStatus(int http_status) { - mDetails = std::unique_ptr
(new Details(http_status, - (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR)); + mDetails = new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); llassert(http_status >= 100 && http_status <= 999); } HttpStatus(const HttpStatus & rhs) { - mDetails = std::unique_ptr
(new Details(*rhs.mDetails)); + mDetails = new Details(*rhs.mDetails); + } + + ~HttpStatus() + { + delete mDetails; } HttpStatus & operator=(const HttpStatus & rhs) @@ -468,7 +472,8 @@ private: void * mErrorData; }; - std::unique_ptr
mDetails; + //boost::unique_ptr
mDetails; + Details * mDetails; }; // end struct HttpStatus -- cgit v1.2.3 From 90ae8b84c6bf515486ec94038abc598520e2320f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 14:22:07 -0700 Subject: Fix headers for gcc build --- indra/llcorehttp/httpcommon.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 2aded492ea..e806201798 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -188,6 +188,7 @@ /// #include "linden_common.h" // Modifies curl/curl.h interfaces +#include "boost/intrusive_ptr.hpp" #include namespace LLCore -- cgit v1.2.3 From d46fe1a1bb0c375ebcfe3c1fe9701e37135acd65 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 23 Mar 2015 14:48:34 -0700 Subject: Microsoft is not nearly picky enough. Headder issues caught by gcc MS likes fine. --- indra/llcorehttp/httpcommon.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index e806201798..e673d7b589 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -189,6 +189,7 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces #include "boost/intrusive_ptr.hpp" +#include "boost/shared_ptr.hpp" #include namespace LLCore -- cgit v1.2.3 From e140118fc41b79e403b299cabe1653af1971e87a Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 25 Mar 2015 11:31:11 -0700 Subject: Replace appearance responder with new LLCore Appearance Handler. Prep for some slight cleanup of the code. Add AP_AVATAR Policy --- indra/llcorehttp/httpcommon.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index e673d7b589..64075f5f20 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -286,6 +286,8 @@ enum HttpError /// 5. Construct an HTTP 301 status code to be treated as success: /// HttpStatus(301, HE_SUCCESS); /// +/// 6. Construct a failed status of HTTP Status 499 with a custom error message +/// HttpStatus(499, "Failed LLSD Response"); struct HttpStatus { @@ -307,6 +309,14 @@ struct HttpStatus (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 = new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); + llassert(http_status >= 100 && http_status <= 999); + mDetails->mMessage = message; + } HttpStatus(const HttpStatus & rhs) { @@ -420,9 +430,6 @@ struct HttpStatus return mDetails->mType; } - // TODO: There must be a better way to do this. Don't want to set these - // values here since they increase the size of a structure that is already - // being passed on the stack. Consider my options /// Returns an optional error message if one has been set. /// std::string getMessage() const -- cgit v1.2.3 From 735364038767694ea29d9b6a168410e6482cc9c2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 27 Mar 2015 17:00:02 -0700 Subject: first set of chnages from code review from Nat --- indra/llcorehttp/httpcommon.h | 75 ++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 36 deletions(-) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 64075f5f20..ada5c1bbe7 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -190,6 +190,7 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces #include "boost/intrusive_ptr.hpp" #include "boost/shared_ptr.hpp" +#include "boost/function.hpp" #include namespace LLCore @@ -294,50 +295,50 @@ struct HttpStatus typedef unsigned short type_enum_t; HttpStatus() - { - mDetails = new Details(LLCORE, HE_SUCCESS); - } + { + mDetails = boost::shared_ptr
(new Details(LLCORE, HE_SUCCESS)); + } HttpStatus(type_enum_t type, short status) - { - mDetails = new Details(type, status); - } + { + mDetails = boost::shared_ptr
(new Details(type, status)); + } HttpStatus(int http_status) - { - mDetails = new Details(http_status, - (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); - llassert(http_status >= 100 && http_status <= 999); - } + { + mDetails = boost::shared_ptr
(new 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 = new Details(http_status, - (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); - llassert(http_status >= 100 && http_status <= 999); - mDetails->mMessage = message; - } + { + mDetails = boost::shared_ptr
(new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR)); + llassert(http_status >= 100 && http_status <= 999); + mDetails->mMessage = message; + } HttpStatus(const HttpStatus & rhs) - { - mDetails = new Details(*rhs.mDetails); - } + { + mDetails = rhs.mDetails; + } ~HttpStatus() - { - delete mDetails; - } + { + } HttpStatus & operator=(const HttpStatus & rhs) - { - // Don't care if lhs & rhs are the same object - mDetails->mType = rhs.mDetails->mType; - mDetails->mStatus = rhs.mDetails->mStatus; - mDetails->mMessage = rhs.mDetails->mMessage; - mDetails->mErrorData = rhs.mDetails->mErrorData; - - return *this; - } + { + mDetails = rhs.mDetails; + return *this; + } + + HttpStatus & clone(const HttpStatus &rhs) + { + mDetails = boost::shared_ptr
(new Details(*rhs.mDetails)); + return *this; + } static const type_enum_t EXT_CURL_EASY = 0; ///< mStatus is an error from a curl_easy_*() call static const type_enum_t EXT_CURL_MULTI = 1; ///< mStatus is an error from a curl_multi_*() call @@ -365,8 +366,7 @@ struct HttpStatus /// which will do the wrong thing in conditional expressions. bool operator==(const HttpStatus & rhs) const { - return (mDetails->mType == rhs.mDetails->mType) && - (mDetails->mStatus == rhs.mDetails->mStatus); + return (*mDetails == *rhs.mDetails); } bool operator!=(const HttpStatus & rhs) const @@ -474,6 +474,10 @@ private: mErrorData(rhs.mErrorData) {} + bool operator == (const Details &rhs) const + { + return (mType == rhs.mType) && (mStatus == rhs.mStatus); + } type_enum_t mType; short mStatus; @@ -481,8 +485,7 @@ private: void * mErrorData; }; - //boost::unique_ptr
mDetails; - Details * mDetails; + boost::shared_ptr
mDetails; }; // end struct HttpStatus -- cgit v1.2.3 From 1c91c8a106a78f2087a3fb4312e428a0128283b4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Apr 2015 10:17:34 -0700 Subject: Adding weak pointer support. Event polling as a coroutine. (incomplete) Groundwork for canceling HttpCoroutineAdapter yields. --- indra/llcorehttp/httpcommon.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index ada5c1bbe7..898d3d47fa 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -190,6 +190,7 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces #include "boost/intrusive_ptr.hpp" #include "boost/shared_ptr.hpp" +#include "boost/weak_ptr.hpp" #include "boost/function.hpp" #include -- cgit v1.2.3 From 907efc9cc9bcf4a935ed0e1bd17b19da2bb99dce Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Tue, 15 Sep 2015 17:01:26 -0700 Subject: MAINT-5507: Remove llcurl, move constant values and untilities to llcorehttp lib --- indra/llcorehttp/httpcommon.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 898d3d47fa..3e98600a92 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -193,6 +193,7 @@ #include "boost/weak_ptr.hpp" #include "boost/function.hpp" #include +#include namespace LLCore { @@ -490,6 +491,19 @@ private: }; // end struct HttpStatus +/// A namespace for several free methods and low level utilities. +namespace LLHttp +{ + typedef boost::shared_ptr CURL_ptr; + + void initialize(); + + CURL_ptr createEasyHandle(); + std::string getCURLVersion(); + + void check_curl_code(CURLcode code, int curl_setopt_option); +} + } // end namespace LLCore #endif // _LLCORE_HTTP_COMMON_H_ -- cgit v1.2.3 From 2a37a8b1cc8796e4c86786017414f919dbaa6fac Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 21 Sep 2015 17:01:26 -0700 Subject: Add cleanup to LLCore prevent occasional crash on exit. --- indra/llcorehttp/httpcommon.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 3e98600a92..1bc20fe6b5 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -497,6 +497,7 @@ namespace LLHttp typedef boost::shared_ptr CURL_ptr; void initialize(); + void cleanup(); CURL_ptr createEasyHandle(); std::string getCURLVersion(); -- cgit v1.2.3 From 8d334ca1bf51dc1a0020f53cdd7a3927bdb7740c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 16 Oct 2015 11:40:48 -0700 Subject: MAINT-5271: Converted internal pointers to internal operation to managed shared pointers. Removed direct cast and dereference of handles. --- indra/llcorehttp/httpcommon.h | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/llcorehttp/httpcommon.h') diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 1bc20fe6b5..b2db01d038 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -209,6 +209,7 @@ namespace LLCore /// becomes invalid and may be recycled for other queued requests. typedef void * HttpHandle; + #define LLCORE_HTTP_HANDLE_INVALID (NULL) /// For internal scheduling and metrics, we use a microsecond -- cgit v1.2.3