# HG changeset patch # User Sebastien Jodogne # Date 1532594016 -7200 # Node ID ad2c32082653029c7477cacb84db3ba9e2706f5d # Parent e7a10626645f55286c34e9932a73672c69126408 Fix OrthancPluginHttpClient() to return the HTTP status on errors diff -r e7a10626645f -r ad2c32082653 Core/HttpClient.cpp --- a/Core/HttpClient.cpp Wed Jul 25 13:15:11 2018 +0200 +++ b/Core/HttpClient.cpp Thu Jul 26 10:33:36 2018 +0200 @@ -184,7 +184,7 @@ }; - static void ThrowException(HttpStatus status) + void HttpClient::ThrowException(HttpStatus status) { switch (status) { diff -r e7a10626645f -r ad2c32082653 Core/HttpClient.h --- a/Core/HttpClient.h Wed Jul 25 13:15:11 2018 +0200 +++ b/Core/HttpClient.h Thu Jul 26 10:33:36 2018 +0200 @@ -288,5 +288,7 @@ void ApplyAndThrowException(Json::Value& answerBody, HttpHeaders& answerHeaders); + + static void ThrowException(HttpStatus status); }; } diff -r e7a10626645f -r ad2c32082653 NEWS --- a/NEWS Wed Jul 25 13:15:11 2018 +0200 +++ b/NEWS Thu Jul 26 10:33:36 2018 +0200 @@ -2,6 +2,7 @@ =============================== * Fix incoming DICOM C-Store filtering for JPEG-LS transfer syntaxes +* Fix OrthancPluginHttpClient() to return the HTTP status on errors Version 1.4.1 (2018-07-17) diff -r e7a10626645f -r ad2c32082653 Plugins/Engine/OrthancPlugins.cpp --- a/Plugins/Engine/OrthancPlugins.cpp Wed Jul 25 13:15:11 2018 +0200 +++ b/Plugins/Engine/OrthancPlugins.cpp Thu Jul 26 10:33:36 2018 +0200 @@ -1865,11 +1865,16 @@ std::string body; HttpClient::HttpHeaders headers; - client.ApplyAndThrowException(body, headers); + bool success = client.Apply(body, headers); // The HTTP request has succeeded *p.httpStatus = static_cast(client.GetLastStatus()); + if (!success) + { + HttpClient::ThrowException(client.GetLastStatus()); + } + // Copy the HTTP headers of the answer, if the plugin requested them if (p.answerHeaders != NULL) {