# HG changeset patch # User Benjamin Golinvaux # Date 1565000894 -7200 # Node ID 8b2d0d2c17a6500c40d7fa0790255faf0dafaa5b # Parent 685c9a2d115f833228e67fb3da7c694682a0d802# Parent acc172f2b7820ac77a68d4972dce95eebc234d91 Merge diff -r 685c9a2d115f -r 8b2d0d2c17a6 Framework/Deprecated/Toolbox/BaseWebService.cpp --- a/Framework/Deprecated/Toolbox/BaseWebService.cpp Mon Aug 05 12:27:27 2019 +0200 +++ b/Framework/Deprecated/Toolbox/BaseWebService.cpp Mon Aug 05 12:28:14 2019 +0200 @@ -75,6 +75,7 @@ { // recreate a failure message with the user payload IWebService::HttpRequestErrorMessage failureMessage(message.GetUri(), + message.GetHttpStatus(), userPayload_.get()); userFailureHandler_->Apply(failureMessage); diff -r 685c9a2d115f -r 8b2d0d2c17a6 Framework/Deprecated/Toolbox/IWebService.h --- a/Framework/Deprecated/Toolbox/IWebService.h Mon Aug 05 12:27:27 2019 +0200 +++ b/Framework/Deprecated/Toolbox/IWebService.h Mon Aug 05 12:28:14 2019 +0200 @@ -106,12 +106,15 @@ private: const std::string& uri_; const Orthanc::IDynamicObject* payload_; + Orthanc::HttpStatus httpStatus_; public: HttpRequestErrorMessage(const std::string& uri, + Orthanc::HttpStatus httpStatus, const Orthanc::IDynamicObject* payload) : uri_(uri), - payload_(payload) + payload_(payload), + httpStatus_(httpStatus) { } @@ -120,6 +123,11 @@ return uri_; } + Orthanc::HttpStatus GetHttpStatus() const + { + return httpStatus_; + } + bool HasPayload() const { return payload_ != NULL; diff -r 685c9a2d115f -r 8b2d0d2c17a6 Framework/Deprecated/Toolbox/OrthancApiClient.cpp --- a/Framework/Deprecated/Toolbox/OrthancApiClient.cpp Mon Aug 05 12:27:27 2019 +0200 +++ b/Framework/Deprecated/Toolbox/OrthancApiClient.cpp Mon Aug 05 12:28:14 2019 +0200 @@ -79,7 +79,7 @@ if (failureHandler_.get() != NULL) { failureHandler_->Apply(IWebService::HttpRequestErrorMessage - (message.GetUri(), userPayload_.get())); + (message.GetUri(), Orthanc::HttpStatus_None, userPayload_.get())); } } @@ -176,7 +176,7 @@ if (failureHandler_.get() != NULL) { failureHandler_->Apply(IWebService::HttpRequestErrorMessage - (message.GetUri(), userPayload_.get())); + (message.GetUri(), message.GetHttpStatus(), userPayload_.get())); } } }; diff -r 685c9a2d115f -r 8b2d0d2c17a6 Platforms/Generic/WebServiceCommandBase.cpp --- a/Platforms/Generic/WebServiceCommandBase.cpp Mon Aug 05 12:27:27 2019 +0200 +++ b/Platforms/Generic/WebServiceCommandBase.cpp Mon Aug 05 12:28:14 2019 +0200 @@ -41,6 +41,8 @@ url_(url), headers_(headers), payload_(payload), + success_(false), + httpStatus_(Orthanc::HttpStatus_None), context_(context), timeoutInSeconds_(timeoutInSeconds) { @@ -62,7 +64,7 @@ } else if (!success_ && failureCallback_.get() != NULL) { - IWebService::HttpRequestErrorMessage message(url_, payload_.get()); + IWebService::HttpRequestErrorMessage message(url_, httpStatus_, payload_.get()); failureCallback_->Apply(message); } } diff -r 685c9a2d115f -r 8b2d0d2c17a6 Platforms/Generic/WebServiceCommandBase.h --- a/Platforms/Generic/WebServiceCommandBase.h Mon Aug 05 12:27:27 2019 +0200 +++ b/Platforms/Generic/WebServiceCommandBase.h Mon Aug 05 12:28:14 2019 +0200 @@ -44,6 +44,7 @@ IWebService::HttpHeaders headers_; std::auto_ptr payload_; bool success_; + Orthanc::HttpStatus httpStatus_; std::string answer_; IWebService::HttpHeaders answerHeaders_; OrthancStone::NativeStoneApplicationContext& context_; diff -r 685c9a2d115f -r 8b2d0d2c17a6 Platforms/Generic/WebServiceDeleteCommand.cpp --- a/Platforms/Generic/WebServiceDeleteCommand.cpp Mon Aug 05 12:27:27 2019 +0200 +++ b/Platforms/Generic/WebServiceDeleteCommand.cpp Mon Aug 05 12:28:14 2019 +0200 @@ -51,6 +51,7 @@ } success_ = client.Apply(answer_, answerHeaders_); + httpStatus_ = client.GetLastStatus(); } } diff -r 685c9a2d115f -r 8b2d0d2c17a6 Platforms/Generic/WebServiceGetCommand.cpp --- a/Platforms/Generic/WebServiceGetCommand.cpp Mon Aug 05 12:27:27 2019 +0200 +++ b/Platforms/Generic/WebServiceGetCommand.cpp Mon Aug 05 12:28:14 2019 +0200 @@ -53,6 +53,7 @@ } success_ = client.Apply(answer_, answerHeaders_); + httpStatus_ = client.GetLastStatus(); } } diff -r 685c9a2d115f -r 8b2d0d2c17a6 Platforms/Generic/WebServicePostCommand.cpp --- a/Platforms/Generic/WebServicePostCommand.cpp Mon Aug 05 12:27:27 2019 +0200 +++ b/Platforms/Generic/WebServicePostCommand.cpp Mon Aug 05 12:28:14 2019 +0200 @@ -54,5 +54,6 @@ } success_ = client.Apply(answer_, answerHeaders_); + httpStatus_ = client.GetLastStatus(); } } diff -r 685c9a2d115f -r 8b2d0d2c17a6 Platforms/Wasm/WasmWebService.cpp --- a/Platforms/Wasm/WasmWebService.cpp Mon Aug 05 12:27:27 2019 +0200 +++ b/Platforms/Wasm/WasmWebService.cpp Mon Aug 05 12:28:14 2019 +0200 @@ -43,12 +43,13 @@ void EMSCRIPTEN_KEEPALIVE WasmWebService_NotifyError(void* failureCallable, const char* uri, + unsigned int httpStatus, void* payload) { if (failureCallable != NULL) { reinterpret_cast*>(failureCallable)-> - Apply(Deprecated::IWebService::HttpRequestErrorMessage(uri, reinterpret_cast(payload))); + Apply(Deprecated::IWebService::HttpRequestErrorMessage(uri, static_cast(httpStatus), reinterpret_cast(payload))); } } diff -r 685c9a2d115f -r 8b2d0d2c17a6 Platforms/Wasm/WasmWebService.js --- a/Platforms/Wasm/WasmWebService.js Mon Aug 05 12:27:27 2019 +0200 +++ b/Platforms/Wasm/WasmWebService.js Mon Aug 05 12:28:14 2019 +0200 @@ -27,7 +27,7 @@ window.WasmWebService_NotifySuccess(callableSuccess, url_, new Uint8Array(this.response), this.response.byteLength, headers, payload); } else { - window.WasmWebService_NotifyError(callableFailure, url_, payload); + window.WasmWebService_NotifyError(callableFailure, url_, xhr.status, payload); } } } @@ -65,7 +65,7 @@ window.WasmWebService_NotifySuccess(callableSuccess, url_, new Uint8Array(this.response), this.response.byteLength, headers, payload); } else { - window.WasmWebService_NotifyError(callableFailure, url_, payload); + window.WasmWebService_NotifyError(callableFailure, url_, xhr.status, payload); } } } @@ -97,7 +97,7 @@ window.WasmWebService_NotifySuccess(callableSuccess, url_, new Uint8Array(this.response), this.response.byteLength, headers, payload); } else { - window.WasmWebService_NotifyError(callableFailure, url_, payload); + window.WasmWebService_NotifyError(callableFailure, url_, xhr.status, payload); } } } diff -r 685c9a2d115f -r 8b2d0d2c17a6 Platforms/Wasm/wasm-application-runner.ts --- a/Platforms/Wasm/wasm-application-runner.ts Mon Aug 05 12:27:27 2019 +0200 +++ b/Platforms/Wasm/wasm-application-runner.ts Mon Aug 05 12:28:14 2019 +0200 @@ -121,7 +121,7 @@ ( window).WasmWebService_NotifyCachedSuccess = ( window).StoneFrameworkModule.cwrap('WasmWebService_NotifyCachedSuccess', null, ['number']); ( window).WasmWebService_NotifySuccess = ( window).StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']); - ( window).WasmWebService_NotifyError = ( window).StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']); + ( window).WasmWebService_NotifyError = ( window).StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number', 'number']); ( window).WasmDelayedCallExecutor_ExecuteCallback = ( window).StoneFrameworkModule.cwrap('WasmDelayedCallExecutor_ExecuteCallback', null, ['number']); // no need to put this into the globals for it's only used in this very module WasmDoAnimation = ( window).StoneFrameworkModule.cwrap('WasmDoAnimation', null, []);