diff Core/HttpServer/MongooseServer.cpp @ 1571:3232f1c995a5

provide the origin of the requests to HTTP handlers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Aug 2015 11:04:19 +0200
parents 2bd2c280f9b5
children f8aae45011c9
line wrap: on
line diff
--- a/Core/HttpServer/MongooseServer.cpp	Sun Aug 23 11:13:03 2015 +0200
+++ b/Core/HttpServer/MongooseServer.cpp	Tue Aug 25 11:04:19 2015 +0200
@@ -634,18 +634,18 @@
 
 
     // Apply the filter, if it is installed
+    char remoteIp[24];
+    sprintf(remoteIp, "%d.%d.%d.%d", 
+            reinterpret_cast<const uint8_t*>(&request->remote_ip) [3], 
+            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]);
+
+    std::string username = GetAuthenticatedUsername(headers);
+
     const IIncomingHttpRequestFilter *filter = that->GetIncomingHttpRequestFilter();
     if (filter != NULL)
     {
-      std::string username = GetAuthenticatedUsername(headers);
-
-      char remoteIp[24];
-      sprintf(remoteIp, "%d.%d.%d.%d", 
-              reinterpret_cast<const uint8_t*>(&request->remote_ip) [3], 
-              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]);
-
       if (!filter->IsAllowed(method, request->uri, remoteIp, username.c_str()))
       {
         output.SendUnauthorized(ORTHANC_REALM);
@@ -728,7 +728,8 @@
       {
         if (that->HasHandler())
         {
-          found = that->GetHandler().Handle(output, method, uri, headers, argumentsGET, body.c_str(), body.size());
+          found = that->GetHandler().Handle(output, RequestOrigin_Http, remoteIp, username.c_str(), 
+                                            method, uri, headers, argumentsGET, body.c_str(), body.size());
         }
       }
       catch (boost::bad_lexical_cast&)