diff options
author | Rider Linden <rider@lindenlab.com> | 2015-11-03 14:22:42 -0800 |
---|---|---|
committer | Rider Linden <rider@lindenlab.com> | 2015-11-03 14:22:42 -0800 |
commit | d64ddb54caacc3d07448d4bf4a90edd3d148cc4f (patch) | |
tree | 3b9957fd18aeda5daf77009922a744b344b6ec4e /indra/llmessage/llcorehttputil.cpp | |
parent | ac0eee2b51f35f4615bc0948ae0eba0679938ac5 (diff) |
MAINT-5820: Add a success/failure result to HTTP body parse method and react to that rather than an "undefined" LLSD
Diffstat (limited to 'indra/llmessage/llcorehttputil.cpp')
-rw-r--r-- | indra/llmessage/llcorehttputil.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 9d3b8fcc1e..9a23ede81b 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -248,6 +248,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons if (!status) { + bool parseSuccess(false); result = LLSD::emptyMap(); LLCore::HttpStatus::type_enum_t errType = status.getType(); @@ -259,7 +260,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons << LL_ENDL; if ((errType >= 400) && (errType < 500)) { - LLSD body = this->parseBody(response); + LLSD body = this->parseBody(response, parseSuccess); if (!body.isUndefined()) { if (!body.isMap()) @@ -362,7 +363,7 @@ public: protected: virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); - virtual LLSD parseBody(LLCore::HttpResponse *response); + virtual LLSD parseBody(LLCore::HttpResponse *response, bool &success); }; //------------------------------------------------------------------------- @@ -377,9 +378,9 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: LLSD result; // const bool emit_parse_errors = false; + bool success(false); - - result = parseBody(response); + result = parseBody(response, success); #if 0 bool parsed = !((response->getBodySize() == 0) || @@ -403,7 +404,7 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: } #endif - if (result.isUndefined()) + if (!success) { #if 1 // Only emit a warning if we failed to parse when 'content-type' == 'application/llsd+xml' @@ -437,8 +438,9 @@ LLSD HttpCoroLLSDHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: return result; } -LLSD HttpCoroLLSDHandler::parseBody(LLCore::HttpResponse *response) +LLSD HttpCoroLLSDHandler::parseBody(LLCore::HttpResponse *response, bool &success) { + success = true; if (response->getBodySize() == 0) return LLSD(); @@ -446,6 +448,7 @@ LLSD HttpCoroLLSDHandler::parseBody(LLCore::HttpResponse *response) if (!LLCoreHttpUtil::responseToLLSD(response, true, result)) { + success = false; return LLSD(); } @@ -467,7 +470,7 @@ public: HttpCoroRawHandler(LLEventStream &reply); virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); - virtual LLSD parseBody(LLCore::HttpResponse *response); + virtual LLSD parseBody(LLCore::HttpResponse *response, bool &success); }; //------------------------------------------------------------------------- @@ -522,8 +525,9 @@ LLSD HttpCoroRawHandler::handleSuccess(LLCore::HttpResponse * response, LLCore:: return result; } -LLSD HttpCoroRawHandler::parseBody(LLCore::HttpResponse *response) +LLSD HttpCoroRawHandler::parseBody(LLCore::HttpResponse *response, bool &success) { + success = true; return LLSD(); } @@ -541,7 +545,7 @@ public: HttpCoroJSONHandler(LLEventStream &reply); virtual LLSD handleSuccess(LLCore::HttpResponse * response, LLCore::HttpStatus &status); - virtual LLSD parseBody(LLCore::HttpResponse *response); + virtual LLSD parseBody(LLCore::HttpResponse *response, bool &success); }; //------------------------------------------------------------------------- @@ -579,8 +583,9 @@ LLSD HttpCoroJSONHandler::handleSuccess(LLCore::HttpResponse * response, LLCore: return result; } -LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response) +LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response, bool &success) { + success = true; BufferArray * body(response->getBody()); if (!body || !body->size()) { @@ -596,6 +601,7 @@ LLSD HttpCoroJSONHandler::parseBody(LLCore::HttpResponse *response) } catch (std::runtime_error e) { + success = false; return LLSD(); } |