summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2015-05-15 12:51:18 -0700
committerRider Linden <rider@lindenlab.com>2015-05-15 12:51:18 -0700
commitf26fb73dd8a7794df580e6a58744d76dde293569 (patch)
tree7a8de73693c46d087fac1a28401097c867f3da7e /indra/llmessage
parent2d79079414f61ad7a6e336e039353c030aa559c8 (diff)
Address Nat's concerns about the const_cast<> and modification of a binary object wrapped in an LLSD object.
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llcorehttputil.cpp17
1 files changed, 17 insertions, 0 deletions
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<U8>(bas), std::istream_iterator<U8>());
+
+ 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<U8>(bas), std::istream_iterator<U8>());
+#endif
return result;
}