Преглед изворни кода

also pass MHD connection handle in URI callback, needed for GNUnet

Christian Grothoff пре 12 година
родитељ
комит
017c372418
5 измењених фајлова са 21 додато и 5 уклоњено
  1. 3 0
      ChangeLog
  2. 5 1
      doc/libmicrohttpd.texi
  3. 7 2
      src/include/microhttpd.h
  4. 2 1
      src/microhttpd/connection.c
  5. 4 1
      src/microhttpd/internal.h

+ 3 - 0
ChangeLog

@@ -1,3 +1,6 @@
+Tue Sep 17 21:32:47 CEST 2013
+	Also pass MHD connection handle in URI log callback. -CG
+
 Fri Sep  6 10:00:44 CEST 2013
 	Improved check for proper OpenSSL version for
 	libmicrospdy. -CG

+ 5 - 1
doc/libmicrohttpd.texi

@@ -631,7 +631,7 @@ parsing will no longer contain the options, which maybe inconvenient for
 logging.  This option should be followed by two arguments, the first
 one must be of the form
 @example
- void * my_logger(void * cls, const char * uri)
+ void * my_logger(void * cls, const char * uri, struct MHD_Connection *con)
 @end example
 where the return value will be passed as
 @code{*con_cls} in calls to the @code{MHD_AccessHandlerCallback}
@@ -644,6 +644,10 @@ rely on the first call to the access handler having
 MHD_OPTION_URI_LOG_CALLBACK.  Finally, @code{uri} will
 be the 0-terminated URI of the request.
 
+Note that during the time of this call, most of the connection's state
+is not initialized (as we have not yet parsed he headers).  However,
+information about the connecting client (IP, socket) is available.
+
 @item MHD_OPTION_HTTPS_MEM_KEY
 @cindex SSL
 @cindex TLS

+ 7 - 2
src/include/microhttpd.h

@@ -121,7 +121,7 @@ extern "C"
  * Current version of the library.
  * 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00093000
+#define MHD_VERSION 0x00093001
 
 /**
  * MHD-internal return code for "YES".
@@ -611,7 +611,7 @@ enum MHD_OPTION
    * logging.  This option should be followed by two arguments, the first
    * one must be of the form
    * 
-   *     void * my_logger(void *cls, const char *uri)
+   *     void * my_logger(void *cls, const char *uri, struct MHD_Connection *con)
    * 
    * where the return value will be passed as
    * (`* con_cls`) in calls to the #MHD_AccessHandlerCallback
@@ -623,6 +623,11 @@ enum MHD_OPTION
    * "cls" will be set to the second argument following
    * #MHD_OPTION_URI_LOG_CALLBACK.  Finally, uri will
    * be the 0-terminated URI of the request.
+   *
+   * Note that during the time of this call, most of the connection's
+   * state is not initialized (as we have not yet parsed he headers).
+   * However, information about the connecting client (IP, socket)
+   * is available.
    */
   MHD_OPTION_URI_LOG_CALLBACK = 7,
 

+ 2 - 1
src/microhttpd/connection.c

@@ -1255,7 +1255,8 @@ parse_initial_message_line (struct MHD_Connection *connection, char *line)
   if (NULL != connection->daemon->uri_log_callback)
     connection->client_context
       = connection->daemon->uri_log_callback (connection->daemon->uri_log_callback_cls, 
-					      uri);
+					      uri,
+					      connection);
   args = strchr (uri, '?');
   if (NULL != args)
     {

+ 4 - 1
src/microhttpd/internal.h

@@ -838,9 +838,12 @@ struct MHD_Connection
  *
  * @param cls closure
  * @param uri uri being accessed
+ * @param con connection handle
  * @return new closure
  */
-typedef void * (*LogCallback)(void * cls, const char * uri);
+typedef void * (*LogCallback)(void * cls, 
+			      const char * uri,
+			      struct MHD_Connection *con);
 
 /**
  * Signature of function called to unescape URIs.  See also