From f26fb73dd8a7794df580e6a58744d76dde293569 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 15 May 2015 12:51:18 -0700 Subject: Address Nat's concerns about the const_cast<> and modification of a binary object wrapped in an LLSD object. --- indra/llmessage/llcorehttputil.cpp | 17 +++++++++++++++++ indra/newview/llfeaturemanager.cpp | 2 ++ 2 files changed, 19 insertions(+) (limited to 'indra') diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 8da62ca839..f8f5866355 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -405,6 +405,22 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: LLCore::BufferArrayStream bas(body); +#if 1 + // This is the slower implementation. It is safe vis-a-vi the const_cast<> and modification + // of a LLSD managed array but contains an extra (potentially large) copy. + // + // *TODO: https://jira.secondlife.com/browse/MAINT-5221 + + LLSD::Binary data; + data.reserve(size); + bas >> std::noskipws; + data.assign(std::istream_iterator(bas), std::istream_iterator()); + + result[HttpCoroutineAdapter::HTTP_RESULTS_RAW] = data; + +#else + // This is disabled because it's dangerous. See the other case for an + // alternate implementation. // We create a new LLSD::Binary object and assign it to the result map. // The LLSD has created it's own copy so we retrieve it asBinary and const cast // the reference so that we can modify it. @@ -416,6 +432,7 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: data.reserve(size); bas >> std::noskipws; data.assign(std::istream_iterator(bas), std::istream_iterator()); +#endif return result; } diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index b701fece5a..c61e11b912 100755 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -520,6 +520,8 @@ void LLFeatureManager::fetchFeatureTableCoro(LLCoros::self& self, std::string ta #endif std::string url = base + "/" + filename; + // testing url below + //url = "http://viewer-settings.secondlife.com/featuretable.2.1.1.208406.txt"; const std::string path = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, filename); -- cgit v1.2.3