changeset 3068:ad37c21ec4db

fix compatibility with civetweb 1.11
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 29 Dec 2018 14:16:43 +0100
parents b89a4288d605
children 3db9697a0a58
files Core/HttpServer/MongooseServer.cpp NEWS Resources/CMake/CivetwebConfiguration.cmake UnitTestsSources/VersionsTests.cpp
diffstat 4 files changed, 46 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/Core/HttpServer/MongooseServer.cpp	Wed Dec 26 11:15:17 2018 +0100
+++ b/Core/HttpServer/MongooseServer.cpp	Sat Dec 29 14:16:43 2018 +0100
@@ -669,18 +669,27 @@
             reinterpret_cast<const uint8_t*>(&request->remote_ip) [2], 
             reinterpret_cast<const uint8_t*>(&request->remote_ip) [1], 
             reinterpret_cast<const uint8_t*>(&request->remote_ip) [0]);
+
+    const char* requestUri = request->uri;
+      
 #elif ORTHANC_ENABLE_CIVETWEB == 1
     const char* remoteIp = request->remote_addr;
+    const char* requestUri = request->local_uri;
 #else
 #error
 #endif
 
+    if (requestUri == NULL)
+    {
+      requestUri = "";
+    }
+      
     std::string username = GetAuthenticatedUsername(headers);
 
     IIncomingHttpRequestFilter *filter = server.GetIncomingHttpRequestFilter();
     if (filter != NULL)
     {
-      if (!filter->IsAllowed(method, request->uri, remoteIp,
+      if (!filter->IsAllowed(method, requestUri, remoteIp,
                              username.c_str(), headers, argumentsGET))
       {
         //output.SendUnauthorized(server.GetRealm());
@@ -744,7 +753,7 @@
     UriComponents uri;
     try
     {
-      Toolbox::SplitUriComponents(uri, request->uri);
+      Toolbox::SplitUriComponents(uri, requestUri);
     }
     catch (OrthancException&)
     {
@@ -775,16 +784,21 @@
   {
     try
     {
-      void* that = NULL;
-
 #if ORTHANC_ENABLE_MONGOOSE == 1
-      that = request->user_data;
+      void *that = request->user_data;
+      const char* requestUri = request->uri;
 #elif ORTHANC_ENABLE_CIVETWEB == 1
       // https://github.com/civetweb/civetweb/issues/409
-      that = mg_get_user_data(mg_get_context(connection));
+      void *that = mg_get_user_data(mg_get_context(connection));
+      const char* requestUri = request->local_uri;
 #else
 #error
-#endif                              
+#endif
+
+      if (requestUri == NULL)
+      {
+        requestUri = "";
+      }
       
       MongooseServer* server = reinterpret_cast<MongooseServer*>(that);
 
@@ -846,7 +860,7 @@
           }
           else
           {
-            server->GetExceptionFormatter()->Format(output, e, method, request->uri);
+            server->GetExceptionFormatter()->Format(output, e, method, requestUri);
           }
         }
         catch (OrthancException&)
--- a/NEWS	Wed Dec 26 11:15:17 2018 +0100
+++ b/NEWS	Sat Dec 29 14:16:43 2018 +0100
@@ -5,8 +5,10 @@
 -----------
 
 * Fix issue #118 (Wording in Configuration.json regarding SynchronousCMove)
-* Fixed Orthanc Explorer on IE and Firefox: Explorer always show "to many results"
+* Fixed Orthanc Explorer on IE and Firefox: Explorer always show "too many results"
   and it's therefore impossible to browse the content.
+* Upgraded dependencies for static and Windows builds:
+  - civetweb 1.11
 
 
 Version 1.5.1 (2018-12-20)
--- a/Resources/CMake/CivetwebConfiguration.cmake	Wed Dec 26 11:15:17 2018 +0100
+++ b/Resources/CMake/CivetwebConfiguration.cmake	Sat Dec 29 14:16:43 2018 +0100
@@ -1,7 +1,7 @@
 if (STATIC_BUILD OR NOT USE_SYSTEM_CIVETWEB)
-  set(CIVETWEB_SOURCES_DIR ${CMAKE_BINARY_DIR}/civetweb-1.9.1)
-  set(CIVETWEB_URL "http://www.orthanc-server.com/downloads/third-party/civetweb-1.9.1.tar.gz")
-  set(CIVETWEB_MD5 "c713f7336582d1a78897971260c67c2a")
+  set(CIVETWEB_SOURCES_DIR ${CMAKE_BINARY_DIR}/civetweb-1.11)
+  set(CIVETWEB_URL "http://www.orthanc-server.com/downloads/third-party/civetweb-1.11.tar.gz")
+  set(CIVETWEB_MD5 "b6d2175650a27924bccb747cbe084cd4")
 
   DownloadPackage(${CIVETWEB_MD5} ${CIVETWEB_URL} "${CIVETWEB_SOURCES_DIR}")
 
--- a/UnitTestsSources/VersionsTests.cpp	Wed Dec 26 11:15:17 2018 +0100
+++ b/UnitTestsSources/VersionsTests.cpp	Sat Dec 29 14:16:43 2018 +0100
@@ -47,7 +47,11 @@
 #include <iconv.h>
 
 #if ORTHANC_ENABLE_SSL == 1
-#include <openssl/opensslv.h>
+#  include <openssl/opensslv.h>
+#endif
+
+#if ORTHANC_ENABLE_CIVETWEB == 1
+#  include <civetweb.h>
 #endif
 
 
@@ -173,4 +177,17 @@
 #endif
 }
 
+
+#if ORTHANC_ENABLE_CIVETWEB == 1
+TEST(Version, Civetweb)
+{
+  ASSERT_EQ(1, CIVETWEB_VERSION_MAJOR);
+  ASSERT_EQ(11, CIVETWEB_VERSION_MINOR);
+  ASSERT_EQ(0, CIVETWEB_VERSION_PATCH);
+}
 #endif
+
+
+#endif
+
+