diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h index af3578de856647d1cba1741745d9d04a8db40f9a..9ff0a24d75fa2e3bfa96b91b3c96519ca88471f1 100644 --- a/indra/llcommon/llstring.h +++ b/indra/llcommon/llstring.h @@ -315,6 +315,7 @@ class LLStringUtilBase static void trimHead(string_type& string); static void trimTail(string_type& string); + static void trimTail(string_type& string, const string_type& tokens); static void trim(string_type& string) { trimHead(string); trimTail(string); } static void truncate(string_type& string, size_type count); @@ -1376,13 +1377,29 @@ void LLStringUtilBase<T>::trimHead(string_type& string) template<class T> void LLStringUtilBase<T>::trimTail(string_type& string) { - if( string.size() ) + if(!string.empty()) { size_type len = string.length(); size_type i = len; while( i > 0 && LLStringOps::isSpace( string[i-1] ) ) { - i--; + --i; + } + + string.erase( i, len - i ); + } +} + +template<class T> +void LLStringUtilBase<T>::trimTail(string_type& string, const string_type& tokens) +{ + if(!string.empty()) + { + size_type len = string.length(); + size_type i = len; + while( i > 0 && (tokens.find_first_of(string[i-1]) != string_type::npos) ) + { + --i; } string.erase( i, len - i ); @@ -1395,6 +1412,9 @@ void LLStringUtilBase<T>::trimTail(string_type& string) template<class T> void LLStringUtilBase<T>::addCRLF(string_type& string) { + if (string.empty()) + return; + const T LF = 10; const T CR = 13; @@ -1437,6 +1457,9 @@ void LLStringUtilBase<T>::addCRLF(string_type& string) template<class T> void LLStringUtilBase<T>::removeCRLF(string_type& string) { + if (string.empty()) + return; + const T CR = 13; size_type cr_count = 0; diff --git a/indra/llcorehttp/llhttpconstants.cpp b/indra/llcorehttp/llhttpconstants.cpp index 30c0fe1892d0dbef11da813e5c722e3ad48f0eff..bb6edcc85a306c31b1b710f2b32ade656d18659f 100755 --- a/indra/llcorehttp/llhttpconstants.cpp +++ b/indra/llcorehttp/llhttpconstants.cpp @@ -31,6 +31,8 @@ // for curl_getdate() (apparently parsing RFC 1123 dates is hard) #include <curl/curl.h> +#include <boost/algorithm/string.hpp> + // Outgoing headers. Do *not* use these to check incoming headers. // For incoming headers, use the lower-case headers, below. const std::string HTTP_OUT_HEADER_ACCEPT("Accept"); @@ -134,3 +136,76 @@ const std::string HTTP_VERB_MOVE("MOVE"); const std::string HTTP_VERB_OPTIONS("OPTIONS"); const std::string HTTP_VERB_PATCH("PATCH"); const std::string HTTP_VERB_COPY("COPY"); + +const std::string& httpMethodAsVerb(EHTTPMethod method) +{ + static const std::string VERBS [] = + { + HTTP_VERB_INVALID, + HTTP_VERB_HEAD, + HTTP_VERB_GET, + HTTP_VERB_PUT, + HTTP_VERB_POST, + HTTP_VERB_DELETE, + HTTP_VERB_MOVE, + HTTP_VERB_OPTIONS, + HTTP_VERB_PATCH, + HTTP_VERB_COPY + }; + if (((S32) method <= 0) || ((S32) method >= HTTP_METHOD_COUNT)) + { + return VERBS[0]; + } + return VERBS[method]; +} + +EHTTPMethod httpVerbAsMethod(const std::string& verb) +{ + static const std::string VERBS [] = { + HTTP_VERB_INVALID, + HTTP_VERB_HEAD, + HTTP_VERB_GET, + HTTP_VERB_PUT, + HTTP_VERB_POST, + HTTP_VERB_DELETE, + HTTP_VERB_MOVE, + HTTP_VERB_OPTIONS, + HTTP_VERB_PATCH, + HTTP_VERB_COPY + }; + + for (int i = 0; i<HTTP_METHOD_COUNT; ++i) + { + if (VERBS[i] == verb) + return (EHTTPMethod) i; + } + return HTTP_INVALID; +} + +std::string get_base_cap_url(std::string url) +{ + std::vector<std::string> url_parts; + boost::algorithm::split(url_parts, url, boost::is_any_of("/")); + + // This is a normal linden-style CAP url. + if(url_parts.size() >= 4 && url_parts[3] == "cap") + { + url_parts.resize(5); + return boost::algorithm::join(url_parts, "/"); + } + // Maybe OpenSim? Just cut off the query string and last /. + else + { + size_t query_pos = url.find_first_of('\?'); + + if(query_pos != std::string::npos) + { + LLStringUtil::truncate(url, query_pos); + } + + static const std::string tokens(" /\?"); + LLStringUtil::trimTail(url, tokens); + + return url; + } +} diff --git a/indra/llcorehttp/llhttpconstants.h b/indra/llcorehttp/llhttpconstants.h index 150547a4e2b995fbf69531701e9c23412b5bb4cb..ed337be3e5dacc92f294119b2795b12a1221107e 100755 --- a/indra/llcorehttp/llhttpconstants.h +++ b/indra/llcorehttp/llhttpconstants.h @@ -119,6 +119,11 @@ enum EHTTPMethod // Parses 'Retry-After' header contents and returns seconds until retry should occur. bool getSecondsUntilRetryAfter(const std::string& retry_after, F32& seconds_to_wait); +const std::string& httpMethodAsVerb(EHTTPMethod method); +EHTTPMethod httpVerbAsMethod(const std::string&); + +std::string get_base_cap_url(std::string url); + //// HTTP Headers ///// // Outgoing headers. Do *not* use these to check incoming headers. diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 9e6a1daa16c193bcf39884c557dbd9886978abae..537d9f38a884e47a578b35cc8fef6a1e200ca509 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -586,12 +586,10 @@ class LLMeshHandlerBase : public LLCore::HttpHandler, mRequestedBytes(requested_bytes) {} - virtual ~LLMeshHandlerBase() - {} + virtual ~LLMeshHandlerBase() = default; -protected: - LLMeshHandlerBase(const LLMeshHandlerBase &); // Not defined - void operator=(const LLMeshHandlerBase &); // Not defined + LLMeshHandlerBase(const LLMeshHandlerBase &) = delete; // Not defined + LLMeshHandlerBase& operator=(const LLMeshHandlerBase &) = delete; // Not defined public: virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); @@ -622,13 +620,11 @@ class LLMeshHeaderHandler : public LLMeshHandlerBase } virtual ~LLMeshHeaderHandler(); -protected: - LLMeshHeaderHandler(const LLMeshHeaderHandler &); // Not defined - void operator=(const LLMeshHeaderHandler &); // Not defined + LLMeshHeaderHandler(const LLMeshHeaderHandler &) = delete; // Not defined + LLMeshHeaderHandler& operator=(const LLMeshHeaderHandler &) = delete; // Not defined -public: - virtual void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size); - virtual void processFailure(LLCore::HttpStatus status); + void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size) override; + void processFailure(LLCore::HttpStatus status) override; }; @@ -648,13 +644,11 @@ class LLMeshLODHandler : public LLMeshHandlerBase } virtual ~LLMeshLODHandler(); -protected: - LLMeshLODHandler(const LLMeshLODHandler &); // Not defined - void operator=(const LLMeshLODHandler &); // Not defined + LLMeshLODHandler(const LLMeshLODHandler &) = delete; // Not defined + LLMeshLODHandler& operator=(const LLMeshLODHandler &) = delete; // Not defined -public: - virtual void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size); - virtual void processFailure(LLCore::HttpStatus status); + void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size) override; + void processFailure(LLCore::HttpStatus status) override; public: S32 mLOD; @@ -674,13 +668,11 @@ class LLMeshSkinInfoHandler : public LLMeshHandlerBase {} virtual ~LLMeshSkinInfoHandler(); -protected: - LLMeshSkinInfoHandler(const LLMeshSkinInfoHandler &); // Not defined - void operator=(const LLMeshSkinInfoHandler &); // Not defined + LLMeshSkinInfoHandler(const LLMeshSkinInfoHandler &) = delete; // Not defined + LLMeshSkinInfoHandler& operator=(const LLMeshSkinInfoHandler &) = delete; // Not defined -public: - virtual void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size); - virtual void processFailure(LLCore::HttpStatus status); + void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size) override; + void processFailure(LLCore::HttpStatus status) override; public: LLUUID mMeshID; @@ -700,13 +692,11 @@ class LLMeshDecompositionHandler : public LLMeshHandlerBase {} virtual ~LLMeshDecompositionHandler(); -protected: - LLMeshDecompositionHandler(const LLMeshDecompositionHandler &); // Not defined - void operator=(const LLMeshDecompositionHandler &); // Not defined + LLMeshDecompositionHandler(const LLMeshDecompositionHandler &) = delete; // Not defined + LLMeshDecompositionHandler& operator=(const LLMeshDecompositionHandler &) = delete; // Not defined -public: - virtual void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size); - virtual void processFailure(LLCore::HttpStatus status); + void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size) override; + void processFailure(LLCore::HttpStatus status) override; public: LLUUID mMeshID; @@ -726,13 +716,11 @@ class LLMeshPhysicsShapeHandler : public LLMeshHandlerBase {} virtual ~LLMeshPhysicsShapeHandler(); -protected: - LLMeshPhysicsShapeHandler(const LLMeshPhysicsShapeHandler &); // Not defined - void operator=(const LLMeshPhysicsShapeHandler &); // Not defined + LLMeshPhysicsShapeHandler(const LLMeshPhysicsShapeHandler &) = delete; // Not defined + LLMeshPhysicsShapeHandler operator=(const LLMeshPhysicsShapeHandler &) = delete; // Not defined -public: - virtual void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size); - virtual void processFailure(LLCore::HttpStatus status); + void processData(LLCore::BufferArray * body, S32 body_offset, U8 * data, S32 data_size) override; + void processFailure(LLCore::HttpStatus status) override; public: LLUUID mMeshID; diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 5fc3764b12e4a8a2cad578d967bbe26c823e4e99..9ca9feff2b29afabc61a1862820c182f059b799f 100644 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -467,7 +467,7 @@ class LLMeshUploadThread final : public LLThread, public LLCore::HttpHandler ~LLMeshUploadThread(); bool finished() const { return mFinished; } - virtual void run(); + void run() override; void preStart(); void discard() ; bool isDiscarded() const; @@ -488,7 +488,7 @@ class LLMeshUploadThread final : public LLThread, public LLCore::HttpHandler void setUploadObserverHandle(LLHandle<LLWholeModelUploadObserver> observer_handle) { mUploadObserverHandle = observer_handle; } // Inherited from LLCore::HttpHandler - virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); + void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response) override; LLViewerFetchedTexture* FindViewerTexture(const LLImportMaterial& material); diff --git a/indra/newview/llviewerassetstorage.cpp b/indra/newview/llviewerassetstorage.cpp index 25e426c6ea9c4f9bf7a4cd1a53a3c260815cbb4c..b44684f0a3e67497e79dae4ba6b6217a4214fc2c 100644 --- a/indra/newview/llviewerassetstorage.cpp +++ b/indra/newview/llviewerassetstorage.cpp @@ -661,7 +661,6 @@ std::string LLViewerAssetStorage::getAssetURL(const std::string& cap_url, const void LLViewerAssetStorage::logAssetStorageInfo() { - LLMemory::logMemoryInfo(true); LL_INFOS("AssetStorage") << "Active coros " << mAssetCoroCount << LL_ENDL; LL_INFOS("AssetStorage") << "mPendingDownloads size " << mPendingDownloads.size() << LL_ENDL; LL_INFOS("AssetStorage") << "mCountStarted " << mCountStarted << LL_ENDL;