commit 017c372418745036838314c0bf6cefba1773d3d9
parent a2425da6f9ba532d8a82906cdbb9ea6076d6a091
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 17 Sep 2013 19:33:20 +0000
also pass MHD connection handle in URI callback, needed for GNUnet
Diffstat:
5 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/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
diff --git a/doc/libmicrohttpd.texi b/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
diff --git a/src/include/microhttpd.h b/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,
diff --git a/src/microhttpd/connection.c b/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)
{
diff --git a/src/microhttpd/internal.h b/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