gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 04/05: MHD_queue_response(): refuse 1xx codes in HTTP/1.


From: gnunet
Subject: [libmicrohttpd] 04/05: MHD_queue_response(): refuse 1xx codes in HTTP/1.0 mode
Date: Sun, 13 Jun 2021 20:55:25 +0200

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit a60173864e4e50fab7676653cfce04421828cef3
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Jun 13 17:23:19 2021 +0300

    MHD_queue_response(): refuse 1xx codes in HTTP/1.0 mode
    
    See https://datatracker.ietf.org/doc/html/rfc7231#section-6.2
---
 src/microhttpd/connection.c | 39 +++++++++++++++++++++++++++++++++------
 1 file changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index 3d98f917..e274ace5 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -4247,12 +4247,6 @@ MHD_queue_response (struct MHD_Connection *connection,
 {
   struct MHD_Daemon *daemon;
 
-  if ( (NULL == connection) ||
-       (NULL == response) ||
-       (NULL != connection->response) ||
-       ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) &&
-         (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) )
-    return MHD_NO;
   daemon = connection->daemon;
 
   if (daemon->shutdown)
@@ -4271,6 +4265,14 @@ MHD_queue_response (struct MHD_Connection *connection,
     return MHD_NO;
   }
 #endif
+
+  if ( (NULL == connection) ||
+       (NULL == response) ||
+       (NULL != connection->response) ||
+       ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) &&
+         (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) )
+    return MHD_NO;
+
 #ifdef UPGRADE_SUPPORT
   if ( (NULL != response->upgrade_handler) &&
        (0 == (daemon->options & MHD_ALLOW_UPGRADE)) )
@@ -4304,6 +4306,31 @@ MHD_queue_response (struct MHD_Connection *connection,
 #endif
     return MHD_NO;
   }
+  if (200 > (status_code & (~MHD_ICY_FLAG)))
+  {
+    if (MHD_HTTP_VER_1_0 == connection->http_ver)
+    {
+#ifdef HAVE_MESSAGES
+      MHD_DLOG (daemon,
+                _ ("Wrong status code (%u) refused. " \
+                   "HTTP/1.0 clients do not support 1xx status codes!\n"),
+                (status_code & (~MHD_ICY_FLAG)));
+#endif
+      return MHD_NO;
+    }
+    if (0 != response->flags & (MHD_RF_HTTP_VERSION_1_0_ONLY
+                                | MHD_RF_HTTP_VERSION_1_0_RESPONSE))
+    {
+#ifdef HAVE_MESSAGES
+      MHD_DLOG (daemon,
+                _ ("Wrong status code (%u) refused. " \
+                   "HTTP/1.0 reply mode does not support 1xx status codes!\n"),
+                (status_code & (~MHD_ICY_FLAG)));
+#endif
+      return MHD_NO;
+    }
+  }
+
   MHD_increment_response_rc (response);
   connection->response = response;
   connection->responseCode = status_code;

-- 
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]