# HG changeset patch # User Sebastien Jodogne # Date 1440668116 -7200 # Node ID d73124f6b43900cd90a1fbfd3f796ab1cfe54aa0 # Parent cd9d99fe32e967e4228bb01364aad3d79e4fa949 configuration option HttpDescribeErrors diff -r cd9d99fe32e9 -r d73124f6b439 Core/HttpServer/HttpOutput.cpp --- a/Core/HttpServer/HttpOutput.cpp Thu Aug 27 10:54:52 2015 +0200 +++ b/Core/HttpServer/HttpOutput.cpp Thu Aug 27 11:35:16 2015 +0200 @@ -302,7 +302,15 @@ stateMachine_.ClearHeaders(); stateMachine_.SetHttpStatus(status); - stateMachine_.SendBody(message, messageSize); + + if (describeErrors_) + { + stateMachine_.SendBody(message, messageSize); + } + else + { + stateMachine_.SendBody(NULL, 0); + } } diff -r cd9d99fe32e9 -r d73124f6b439 Core/HttpServer/HttpOutput.h --- a/Core/HttpServer/HttpOutput.h Thu Aug 27 10:54:52 2015 +0200 +++ b/Core/HttpServer/HttpOutput.h Thu Aug 27 11:35:16 2015 +0200 @@ -114,6 +114,7 @@ StateMachine stateMachine_; bool isDeflateAllowed_; bool isGzipAllowed_; + bool describeErrors_; HttpCompression GetPreferredCompression(size_t bodySize) const; @@ -122,7 +123,8 @@ bool isKeepAlive) : stateMachine_(stream, isKeepAlive), isDeflateAllowed_(false), - isGzipAllowed_(false) + isGzipAllowed_(false), + describeErrors_(true) { } @@ -146,6 +148,16 @@ return isGzipAllowed_; } + void SetDescribeErrorsEnabled(bool enabled) + { + describeErrors_ = enabled; + } + + bool IsDescribeErrorsEnabled() const + { + return describeErrors_; + } + void SendStatus(HttpStatus status, const char* message, size_t messageSize); diff -r cd9d99fe32e9 -r d73124f6b439 Core/HttpServer/MongooseServer.cpp --- a/Core/HttpServer/MongooseServer.cpp Thu Aug 27 10:54:52 2015 +0200 +++ b/Core/HttpServer/MongooseServer.cpp Thu Aug 27 11:35:16 2015 +0200 @@ -583,6 +583,7 @@ MongooseOutputStream stream(connection); HttpOutput output(stream, that->IsKeepAliveEnabled()); + output.SetDescribeErrorsEnabled(that->IsDescribeErrorsEnabled()); // Check remote calls if (!that->IsRemoteAccessAllowed() && @@ -831,6 +832,7 @@ filter_ = NULL; keepAlive_ = false; httpCompression_ = true; + describeErrors_ = true; #if ORTHANC_SSL_ENABLED == 1 // Check for the Heartbleed exploit @@ -980,6 +982,12 @@ httpCompression_ = enabled; LOG(WARNING) << "HTTP compression is " << (enabled ? "enabled" : "disabled"); } + + void MongooseServer::SetDescribeErrorsEnabled(bool enabled) + { + describeErrors_ = enabled; + LOG(INFO) << "Description of the errors in the HTTP answers is " << (enabled ? "enabled" : "disabled"); + } void MongooseServer::SetIncomingHttpRequestFilter(IIncomingHttpRequestFilter& filter) { diff -r cd9d99fe32e9 -r d73124f6b439 Core/HttpServer/MongooseServer.h --- a/Core/HttpServer/MongooseServer.h Thu Aug 27 10:54:52 2015 +0200 +++ b/Core/HttpServer/MongooseServer.h Thu Aug 27 11:35:16 2015 +0200 @@ -77,6 +77,7 @@ IIncomingHttpRequestFilter* filter_; bool keepAlive_; bool httpCompression_; + bool describeErrors_; bool IsRunning() const; @@ -143,6 +144,13 @@ void SetHttpCompressionEnabled(bool enabled); + bool IsDescribeErrorsEnabled() const + { + return describeErrors_; + } + + void SetDescribeErrorsEnabled(bool enabled); + const IIncomingHttpRequestFilter* GetIncomingHttpRequestFilter() const { return filter_; diff -r cd9d99fe32e9 -r d73124f6b439 NEWS --- a/NEWS Thu Aug 27 10:54:52 2015 +0200 +++ b/NEWS Thu Aug 27 11:35:16 2015 +0200 @@ -31,6 +31,7 @@ * Improved error codes * Many code refactorings * If error while calling the REST API, the answer body contains an error description + (this feature can be disabled with the "HttpDescribeErrors" option) * Upgrade to curl 7.44.0 for static and Windows builds * Upgrade to libcurl 1.0.2d for static and Windows builds * Bypass zlib uncompression if "StorageCompression" is enabled and HTTP client supports deflate diff -r cd9d99fe32e9 -r d73124f6b439 OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Thu Aug 27 10:54:52 2015 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Thu Aug 27 11:35:16 2015 +0200 @@ -82,7 +82,15 @@ { if (configuration_.isMember(parameter)) { - return configuration_[parameter].asString(); + if (configuration_[parameter].type() != Json::stringValue) + { + LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a string"; + throw OrthancException(ErrorCode_BadParameterType); + } + else + { + return configuration_[parameter].asString(); + } } else { @@ -96,7 +104,15 @@ { if (configuration_.isMember(parameter)) { - return configuration_[parameter].asBool(); + if (configuration_[parameter].type() != Json::booleanValue) + { + LOG(ERROR) << "The configuration option \"" << parameter << "\" must be a Boolean (true or false)"; + throw OrthancException(ErrorCode_BadParameterType); + } + else + { + return configuration_[parameter].asBool(); + } } else { @@ -382,7 +398,15 @@ if (configuration_.isMember(parameter)) { - return configuration_[parameter].asInt(); + if (configuration_[parameter].type() != Json::intValue) + { + LOG(ERROR) << "The configuration option \"" << parameter << "\" must be an integer"; + throw OrthancException(ErrorCode_BadParameterType); + } + else + { + return configuration_[parameter].asInt(); + } } else { diff -r cd9d99fe32e9 -r d73124f6b439 OrthancServer/main.cpp --- a/OrthancServer/main.cpp Thu Aug 27 10:54:52 2015 +0200 +++ b/OrthancServer/main.cpp Thu Aug 27 11:35:16 2015 +0200 @@ -423,6 +423,7 @@ httpServer.SetRemoteAccessAllowed(Configuration::GetGlobalBoolParameter("RemoteAccessAllowed", false)); httpServer.SetKeepAliveEnabled(Configuration::GetGlobalBoolParameter("KeepAlive", false)); httpServer.SetHttpCompressionEnabled(Configuration::GetGlobalBoolParameter("HttpCompressionEnabled", true)); + httpServer.SetDescribeErrorsEnabled(Configuration::GetGlobalBoolParameter("HttpDescribeErrors", true)); httpServer.SetIncomingHttpRequestFilter(httpFilter); httpServer.SetAuthenticationEnabled(Configuration::GetGlobalBoolParameter("AuthenticationEnabled", false)); diff -r cd9d99fe32e9 -r d73124f6b439 Resources/Configuration.json --- a/Resources/Configuration.json Thu Aug 27 10:54:52 2015 +0200 +++ b/Resources/Configuration.json Thu Aug 27 11:35:16 2015 +0200 @@ -42,19 +42,41 @@ ], + /** * Configuration of the HTTP server **/ + // Enable the HTTP server. If this parameter is set to "false", + // Orthanc acts as a pure DICOM server. The REST API and Orthanc + // Explorer will not be available. + "HttpServerEnabled" : true, + // HTTP port for the REST services and for the GUI "HttpPort" : 8042, + // When the following option is "true", if an error is encountered + // while calling the REST API, a JSON message describing the error + // is put in the HTTP answer. This feature can be disabled if the + // HTTP client does not properly handles such answers. + "HttpDescribeErrors" : true, + + // Enable HTTP compression to improve network bandwidth utilization, + // at the expense of more computations on the server. Orthanc + // supports the "gzip" and "deflate" HTTP encodings. + "HttpCompressionEnabled" : true, + /** * Configuration of the DICOM server **/ + // Enable the DICOM server. If this parameter is set to "false", + // Orthanc acts as a pure REST server. It will not be possible to + // receive files or to do query/retrieve through the DICOM protocol. + "DicomServerEnabled" : true, + // The DICOM Application Entity Title "DicomAet" : "ORTHANC", @@ -81,6 +103,7 @@ "RleTransferSyntaxAccepted" : true, + /** * Security-related options for the HTTP server **/ @@ -149,6 +172,17 @@ // Set the timeout for HTTP requests issued by Orthanc (in seconds). "HttpTimeout" : 10, + // Enable the verification of the peers during HTTPS requests. + // Reference: http://curl.haxx.se/docs/sslcerts.html + "HttpsVerifyPeers" : true, + + // Path to the CA (certification authority) certificates to validate + // peers in HTTPS requests. From curl documentation ("--cacert" + // option): "Tells curl to use the specified certificate file to + // verify the peers. The file may contain multiple CA + // certificates. The certificate(s) must be in PEM format." + "HttpsCACertificates" : "", + /** @@ -173,16 +207,6 @@ // patient, a study or a series is considered as stable. "StableAge" : 60, - // Enable the HTTP server. If this parameter is set to "false", - // Orthanc acts as a pure DICOM server. The REST API and Orthanc - // Explorer will not be available. - "HttpServerEnabled" : true, - - // Enable the DICOM server. If this parameter is set to "false", - // Orthanc acts as a pure REST server. It will not be possible to - // receive files or to do query/retrieve through the DICOM protocol. - "DicomServerEnabled" : true, - // By default, Orthanc compares AET (Application Entity Titles) in a // case-insensitive way. Setting this option to "true" will enable // case-sensitive matching. @@ -236,21 +260,5 @@ // When handling a C-Find SCP request, setting this flag to "false" // will enable case-insensitive match for PN value representation // (such as PatientName). By default, the search is case-insensitive. - "CaseSensitivePN" : false, - - // Enable HTTP compression to improve network bandwidth utilization, - // at the expense of more computations on the server. Orthanc - // supports the "gzip" and "deflate" encodings. - "HttpCompressionEnabled" : true, - - // Enable the verification of the peers during HTTPS requests. - // Reference: http://curl.haxx.se/docs/sslcerts.html - "HttpsVerifyPeers" : true, - - // Path to the CA (certification authority) certificates to validate - // peers in HTTPS requests. From curl documentation ("--cacert" - // option): "Tells curl to use the specified certificate file to - // verify the peers. The file may contain multiple CA - // certificates. The certificate(s) must be in PEM format." - "HttpsCACertificates" : "" + "CaseSensitivePN" : false }