gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 02/02: Added response flag to always send "Connection:"


From: gnunet
Subject: [libmicrohttpd] 02/02: Added response flag to always send "Connection:" header
Date: Thu, 19 Aug 2021 19:15:32 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 6f48db46b16579198fd48862fb8ec4829216ba2d
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Thu Aug 19 20:11:13 2021 +0300

    Added response flag to always send "Connection:" header
---
 src/include/microhttpd.h    | 20 ++++++++++++++------
 src/microhttpd/connection.c |  6 ++++--
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index a5731e23..d2eaeff3 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -96,7 +96,7 @@ extern "C"
  * they are parsed as decimal numbers.
  * Example: 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00097309
+#define MHD_VERSION 0x00097310
 
 /* If generic headers don't work on your platform, include headers
    which define 'va_list', 'size_t', 'ssize_t', 'intptr_t',
@@ -3126,12 +3126,12 @@ enum MHD_ResponseFlags
    * does not implement HTTP/1.1 features, but advertises HTTP/1.1 support.
    * @note Available since #MHD_VERSION 0x00097308
    */
-  MHD_RF_HTTP_1_0_COMPATIBLE_STRICT = 1,
+  MHD_RF_HTTP_1_0_COMPATIBLE_STRICT = 1 << 0,
   /**
    * The same as #MHD_RF_HTTP_1_0_COMPATIBLE_STRICT
    * @note Available since #MHD_VERSION 0x00093701
    */
-  MHD_RF_HTTP_VERSION_1_0_ONLY = 1,
+  MHD_RF_HTTP_VERSION_1_0_ONLY = 1 << 0,
 
   /**
    * Only respond in HTTP 1.0-mode.
@@ -3145,19 +3145,27 @@ enum MHD_ResponseFlags
    * as chunked encoding in requests will be supported still).
    * @note Available since #MHD_VERSION 0x00097308
    */
-  MHD_RF_HTTP_1_0_SERVER = 2,
+  MHD_RF_HTTP_1_0_SERVER = 1 << 1,
   /**
    * The same as #MHD_RF_HTTP_1_0_SERVER
    * @note Available since #MHD_VERSION 0x00096000
    */
-  MHD_RF_HTTP_VERSION_1_0_RESPONSE = 2,
+  MHD_RF_HTTP_VERSION_1_0_RESPONSE = 1 << 1,
 
   /**
    * Disable sanity check preventing clients from manually
    * setting the HTTP content length option.
    * @note Available since #MHD_VERSION 0x00096702
    */
-  MHD_RF_INSANITY_HEADER_CONTENT_LENGTH = 4
+  MHD_RF_INSANITY_HEADER_CONTENT_LENGTH = 1 << 2,
+
+  /**
+   * Enable sending of "Connection: keep-alive" header even for
+   * HTTP/1.1 clients when "Keep-Alive" connection is used.
+   * Disabled by default for HTTP/1.1 clients as per RFC.
+   * @note Available since #MHD_VERSION 0x00097310
+   */
+  MHD_RF_SEND_KEEP_ALIVE_HEADER = 1 << 3
 } _MHD_FIXED_FLAGS_ENUM;
 
 
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index d8561251..9cdc06f1 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -1940,7 +1940,8 @@ build_header_response (struct MHD_Connection *connection)
     }
     else if (MHD_CONN_USE_KEEPALIVE == c->keepalive)
     {
-      if (MHD_HTTP_VER_1_0 == c->http_ver)
+      if ((MHD_HTTP_VER_1_0 == c->http_ver) ||
+          (0 != (r->flags | MHD_RF_SEND_KEEP_ALIVE_HEADER)))
       {
         if (! buffer_append_s (buf, &pos, buf_size,
                                MHD_HTTP_HEADER_CONNECTION ": Keep-Alive\r\n"))
@@ -1954,7 +1955,8 @@ build_header_response (struct MHD_Connection *connection)
   if (! add_user_headers (buf, &pos, buf_size, r, MHD_HEADER_KIND,
                           ! c->rp_props.chunked,
                           (MHD_CONN_MUST_CLOSE == c->keepalive),
-                          (MHD_HTTP_VER_1_0 == c->http_ver) &&
+                          ((MHD_HTTP_VER_1_0 == c->http_ver) ||
+                           (0 != (r->flags | MHD_RF_SEND_KEEP_ALIVE_HEADER))) 
&&
                           (MHD_CONN_USE_KEEPALIVE == c->keepalive)))
     return MHD_NO;
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]