changeset 943:8b2d0d2c17a6 toa2019080501

Merge
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 05 Aug 2019 12:28:14 +0200
parents 685c9a2d115f (current diff) acc172f2b782 (diff)
children 8b9bc91eda6b
files
diffstat 11 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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;
--- 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()));
       }
     }
   };
--- 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);
     }
   }
--- 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<Orthanc::IDynamicObject>  payload_;
     bool                                    success_;
+    Orthanc::HttpStatus                     httpStatus_;
     std::string                             answer_;
     IWebService::HttpHeaders                answerHeaders_;
     OrthancStone::NativeStoneApplicationContext&          context_;
--- 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();
   }
 
 }
--- 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();
   }
 
 }
--- 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();
   }
 }
--- 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<OrthancStone::MessageHandler<Deprecated::IWebService::HttpRequestErrorMessage>*>(failureCallable)->
-        Apply(Deprecated::IWebService::HttpRequestErrorMessage(uri, reinterpret_cast<Orthanc::IDynamicObject*>(payload)));
+        Apply(Deprecated::IWebService::HttpRequestErrorMessage(uri, static_cast<Orthanc::HttpStatus>(httpStatus), reinterpret_cast<Orthanc::IDynamicObject*>(payload)));
     }
   }
 
--- 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);
         }
       }
     }
--- 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 @@
 
     (<any> window).WasmWebService_NotifyCachedSuccess = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifyCachedSuccess', null, ['number']);
     (<any> window).WasmWebService_NotifySuccess = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifySuccess', null, ['number', 'string', 'array', 'number', 'number']);
-    (<any> window).WasmWebService_NotifyError = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']);
+    (<any> window).WasmWebService_NotifyError = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number', 'number']);
     (<any> window).WasmDelayedCallExecutor_ExecuteCallback = (<any> 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 = (<any> window).StoneFrameworkModule.cwrap('WasmDoAnimation', null, []);