libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit cfea15fe53e1d84d38de88651f31122de6369143
parent f4a4a70d43a3c99915190447356c1080feb8867b
Author: Christian Grothoff <christian@grothoff.org>
Date:   Mon, 20 May 2013 10:30:32 +0000

-fix 2886

Diffstat:
MChangeLog | 5+++++
Mdoc/libmicrohttpd.texi | 12++++++++++++
Msrc/include/microhttpd.h | 14+++++++++++++-
Msrc/microhttpd/connection.c | 2++
4 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +Mon May 20 12:29:35 CEST 2013 + Added MHD_CONNECTION_INFO_CONNECTION_FD to allow clients + direct access to connection socket; useful for COMET + applications that need to disable NAGLE (#2886). -CG + Mon May 15 12:49:01 CEST 2013 Fixing #2859. -CG diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi @@ -2138,6 +2138,18 @@ and then call @code{gnutls_certificate_get_peers()}. Returns information about @code{struct MHD_Daemon} which manages this connection. +@item MHD_CONNECTION_INFO_CONNECTION_FD +Returns the file descriptor (usually a TCP socket) associated with +this connection (in the ``connect-fd'' member of the returned struct). +Note that manipulating the descriptor directly can have problematic +consequences (as in, break HTTP). Applications might use this access +to manipulate TCP options, for example to set the ``TCP-NODELAY'' +option for COMET-like applications. Note that MHD will set TCP-CORK +after sending the HTTP header and clear it after finishing the footers +automatically (if the platform supports it). As the connection +callbacks are invoked in between, those might be used to set different +values for TCP-CORK and TCP-NODELAY in the meantime. + @end table @end deftp diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -791,7 +791,14 @@ enum MHD_ConnectionInfoType /** * Get the 'struct MHD_Daemon' responsible for managing this connection. */ - MHD_CONNECTION_INFO_DAEMON + MHD_CONNECTION_INFO_DAEMON, + + + /** + * Request the file descriptor for the listening socket. + * No extra arguments should be passed. + */ + MHD_CONNECTION_INFO_CONNECTION_FD }; @@ -1852,6 +1859,11 @@ union MHD_ConnectionInfo int /* enum gnutls_protocol */ protocol; /** + * Connect socket + */ + int connect_fd; + + /** * GNUtls session handle, of type "gnutls_session_t". */ void * /* gnutls_session_t */ tls_session; diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -2555,6 +2555,8 @@ MHD_get_connection_info (struct MHD_Connection *connection, return (const union MHD_ConnectionInfo *) &connection->addr; case MHD_CONNECTION_INFO_DAEMON: return (const union MHD_ConnectionInfo *) &connection->daemon; + case MHD_CONNECTION_INFO_CONNECTION_FD: + return (const union MHD_ConnectionInfo *) &connection->socket_fd; default: return NULL; };