Christian Grothoff 12 gadi atpakaļ
vecāks
revīzija
cfea15fe53
4 mainītis faili ar 32 papildinājumiem un 1 dzēšanām
  1. 5 0
      ChangeLog
  2. 12 0
      doc/libmicrohttpd.texi
  3. 13 1
      src/include/microhttpd.h
  4. 2 0
      src/microhttpd/connection.c

+ 5 - 0
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
 

+ 12 - 0
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
 

+ 13 - 1
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
 
 };
 
@@ -1851,6 +1858,11 @@ union MHD_ConnectionInfo
    */
   int /* enum gnutls_protocol */ protocol;
 
+  /**
+   * Connect socket 
+   */
+  int connect_fd;
+
   /**
    * GNUtls session handle, of type "gnutls_session_t".
    */

+ 2 - 0
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;
     };