Browse Source

documentation, adding MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE, releasing 0.9.54

Christian Grothoff 8 năm trước cách đây
mục cha
commit
76cf7d7f58

+ 6 - 0
AUTHORS

@@ -61,3 +61,9 @@ Silvio Clecio <[email protected]>
 Documentation contributions also came from:
 Marco Maggi <[email protected]>
 Sebastian Gerhardt <[email protected]>
+
+Special thanks to:
+Florian Weimer <[email protected]>
+Ramakrishnan Muthukrishnan <[email protected]>
+Gervasa Markham <[email protected]>
+Liz Steininger <[email protected]>

+ 5 - 0
ChangeLog

@@ -1,3 +1,8 @@
+Tue May  2 18:37:53 CEST 2017
+	Update manual. -CG
+	Add MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE.
+	Releasing GNU libmicrohttpd 0.9.54. -CG
+
 Thu Apr 27 22:31:00 CEST 2017
 	Replaced flags MHD_USE_PEDANTIC_CHECKS and MHD_USE_PERMISSIVE_CHECKS by
 	single option MHD_OPTION_STRICT_FOR_CLIENT. Flag MHD_USE_PEDANTIC_CHECKS

+ 3 - 3
configure.ac

@@ -22,14 +22,14 @@
 #
 AC_PREREQ([2.64])
 LT_PREREQ([2.4.0])
-AC_INIT([GNU Libmicrohttpd],[0.9.53],[[email protected]])
+AC_INIT([GNU Libmicrohttpd],[0.9.54],[[email protected]])
 AM_INIT_AUTOMAKE([silent-rules] [subdir-objects])
 AC_CONFIG_HEADERS([MHD_config.h])
 AC_CONFIG_MACRO_DIR([m4])
 
-LIB_VERSION_CURRENT=53
+LIB_VERSION_CURRENT=54
 LIB_VERSION_REVISION=0
-LIB_VERSION_AGE=41
+LIB_VERSION_AGE=42
 AC_SUBST(LIB_VERSION_CURRENT)
 AC_SUBST(LIB_VERSION_REVISION)
 AC_SUBST(LIB_VERSION_AGE)

+ 37 - 8
doc/libmicrohttpd.texi

@@ -496,6 +496,8 @@ that IPv4 addresses are returned by MHD in the IPv6-mapped format
 (the 'struct sockaddr_in6' format will be used for IPv4 and IPv6).
 
 @item MHD_USE_PEDANTIC_CHECKS
+@cindex deprecated
+Deprecated (use @code{MHD_OPTION_STRICT_FOR_CLIENT}).
 Be pedantic about the protocol.
 Specifically, at the moment, this flag causes MHD to reject HTTP
 1.1 connections without a @code{Host} header.  This is required by the
@@ -504,13 +506,6 @@ in what you accept'' norm.  It is recommended to turn this @strong{ON}
 if you are testing clients against MHD, and @strong{OFF} in
 production.
 
-@item MHD_USE_PERMISSIVE_CHECKS
-Be permissive about the protocol, allowing slight deviations that are
-technically not allowed by the RFC.  Specifically, at the moment, this
-flag causes MHD to allow spaces in header field names.  This is
-disallowed by the standard.
-
-
 @item MHD_USE_POLL
 @cindex FD_SETSIZE
 @cindex poll
@@ -735,6 +730,31 @@ should be followed by an @code{unsigned int}.  The default is
 zero, which means no limit on the number of connections
 from the same IP address.
 
+@item MHD_OPTION_LISTEN_BACKLOG_SIZE
+Set the size of the @code{listen()} back log queue of the TCP socket.
+Takes an @code{unsigned int} as the argument.  Default is the
+platform-specific value of @code{SOMAXCONN}.
+
+@item MHD_OPTION_STRICT_FOR_CLIENT
+Specify how strict we should enforce the HTTP protocol.
+Takes an @code{int} as the argument.  Default is zero.
+
+If set to 1, MHD will be strict about the protocol.  Specifically, at
+the moment, this flag uses MHD to reject HTTP 1.1 connections without
+a "Host" header.  This is required by the standard, but of course in
+violation of the "be as liberal as possible in what you accept" norm.
+It is recommended to set this to 1 if you are testing clients against
+MHD, and 0 in production.
+
+If set to -1 MHD will be permissive about the protocol, allowing
+slight deviations that are technically not allowed by the
+RFC. Specifically, at the moment, this flag causes MHD to allow spaces
+in header field names. This is disallowed by the standard.
+
+It is not recommended to set it to -1 on publicly available servers as
+it may potentially lower level of protection.
+
+
 @item MHD_OPTION_SOCK_ADDR
 @cindex bind, restricting bind
 Bind daemon to the supplied socket address. This option should be followed by a
@@ -2823,7 +2843,7 @@ socket was first accepted.  Note that this is NOT the same as the
 
 Takes no extra arguments.
 
-@item MHD_CONNECTION_INFO_TIMEOUT
+@item MHD_CONNECTION_INFO_CONNECTION_TIMEOUT
 Returns pointer to an @code{unsigned int} that is the current timeout
 used for the connection (in seconds, 0 for no timeout).  Note that
 while suspended connections will not timeout, the timeout value
@@ -2831,6 +2851,15 @@ returned for suspended connections will be the timeout that the
 connection will use after it is resumed, and thus might not be zero.
 
 Takes no extra arguments.
+
+@item MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE
+@cindex performance
+Returns pointer to an @code{size_t} that represents the size of the
+HTTP header received from the client. Only valid after the first callback
+to the access handler.
+
+Takes no extra arguments.
+
 @end table
 @end deftp
 

+ 13 - 3
src/include/microhttpd.h

@@ -126,7 +126,7 @@ typedef intptr_t ssize_t;
  * Current version of the library.
  * 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00095300
+#define MHD_VERSION 0x00095400
 
 /**
  * MHD-internal return code for "YES".
@@ -1676,6 +1676,11 @@ union MHD_ConnectionInfo
    */
   MHD_socket connect_fd;
 
+  /**
+   * Size of the client's HTTP header.
+   */
+  size_t header_size;
+
   /**
    * GNUtls session handle, of type "gnutls_session_t".
    */
@@ -1778,12 +1783,17 @@ enum MHD_ConnectionInfoType
    */
   MHD_CONNECTION_INFO_CONNECTION_SUSPENDED,
 
-
   /**
    * Get connection timeout
    * @ingroup request
    */
-  MHD_CONNECTION_INFO_CONNECTION_TIMEOUT
+  MHD_CONNECTION_INFO_CONNECTION_TIMEOUT,
+
+  /**
+   * Return length of the client's HTTP request header.
+   * @ingroup request
+   */
+  MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE
 };
 
 

+ 1 - 0
src/microhttpd/.gitignore

@@ -42,3 +42,4 @@
 /gmon.out
 *.exe
 test_upgrade_tls
+test_http_reasons

+ 9 - 1
src/microhttpd/connection.c

@@ -1831,7 +1831,7 @@ call_connection_handler (struct MHD_Connection *connection)
   processed = 0;
   connection->client_aware = true;
   if (MHD_NO ==
-      connection->daemon->default_handler (connection->daemon-> default_handler_cls,
+      connection->daemon->default_handler (connection->daemon->default_handler_cls,
 					   connection,
                                            connection->url,
 					   connection->method,
@@ -2857,6 +2857,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
           if (0 == line[0])
             {
               connection->state = MHD_CONNECTION_HEADERS_RECEIVED;
+              connection->header_size = (size_t) (line - connection->read_buffer);
               continue;
             }
           if (MHD_NO == process_header_line (connection,
@@ -2892,6 +2893,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection)
           if (0 == line[0])
             {
               connection->state = MHD_CONNECTION_HEADERS_RECEIVED;
+              connection->header_size = (size_t) (line - connection->read_buffer);
               continue;
             }
           continue;
@@ -3402,6 +3404,12 @@ MHD_get_connection_info (struct MHD_Connection *connection,
     case MHD_CONNECTION_INFO_CONNECTION_TIMEOUT:
       connection->connection_timeout_dummy = (unsigned int)connection->connection_timeout;
       return (const union MHD_ConnectionInfo *) &connection->connection_timeout_dummy;
+    case MHD_CONNECTION_INFO_REQUEST_HEADER_SIZE:
+      if ( (MHD_CONNECTION_HEADERS_RECEIVED > connection->state) ||
+           (MHD_CONNECTION_CLOSED == connection->state) ||
+           (MHD_CONNECTION_IN_CLEANUP == connection->state) )
+        return NULL; /* invalid, too early! */
+      return (const union MHD_ConnectionInfo *) &connection->header_size;
     default:
       return NULL;
     }

+ 6 - 0
src/microhttpd/internal.h

@@ -747,6 +747,12 @@ struct MHD_Connection
    */
   size_t write_buffer_append_offset;
 
+  /**
+   * Number of bytes we had in the HTTP header, set once we
+   * pass #MHD_CONNECTION_HEADERS_RECEIVED.
+   */
+  size_t header_size;
+
   /**
    * How many more bytes of the body do we expect
    * to read? #MHD_SIZE_UNKNOWN for unknown.