Mercurial > hg > orthanc
comparison Plugins/Engine/OrthancPlugins.cpp @ 2787:ad2c32082653
Fix OrthancPluginHttpClient() to return the HTTP status on errors
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 26 Jul 2018 10:33:36 +0200 |
parents | a21b244efb37 |
children | 6e3a60b85da6 |
comparison
equal
deleted
inserted
replaced
2786:e7a10626645f | 2787:ad2c32082653 |
---|---|
1863 } | 1863 } |
1864 | 1864 |
1865 std::string body; | 1865 std::string body; |
1866 HttpClient::HttpHeaders headers; | 1866 HttpClient::HttpHeaders headers; |
1867 | 1867 |
1868 client.ApplyAndThrowException(body, headers); | 1868 bool success = client.Apply(body, headers); |
1869 | 1869 |
1870 // The HTTP request has succeeded | 1870 // The HTTP request has succeeded |
1871 *p.httpStatus = static_cast<uint16_t>(client.GetLastStatus()); | 1871 *p.httpStatus = static_cast<uint16_t>(client.GetLastStatus()); |
1872 | |
1873 if (!success) | |
1874 { | |
1875 HttpClient::ThrowException(client.GetLastStatus()); | |
1876 } | |
1872 | 1877 |
1873 // Copy the HTTP headers of the answer, if the plugin requested them | 1878 // Copy the HTTP headers of the answer, if the plugin requested them |
1874 if (p.answerHeaders != NULL) | 1879 if (p.answerHeaders != NULL) |
1875 { | 1880 { |
1876 Json::Value json = Json::objectValue; | 1881 Json::Value json = Json::objectValue; |