gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r37227 - in libmicrohttpd: . src/include src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r37227 - in libmicrohttpd: . src/include src/microhttpd
Date: Wed, 1 Jun 2016 22:02:30 +0200

Author: grothoff
Date: 2016-06-01 22:02:30 +0200 (Wed, 01 Jun 2016)
New Revision: 37227

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/include/microhttpd.h
   libmicrohttpd/src/microhttpd/connection.c
Log:
do not generate Content-Length header for 1xx/204/304 replies, also suppress 
transmission of message body in these cases

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2016-06-01 20:00:51 UTC (rev 37226)
+++ libmicrohttpd/ChangeLog     2016-06-01 20:02:30 UTC (rev 37227)
@@ -1,3 +1,6 @@
+Wed Jun  1 21:59:34 CEST 2016
+       Do not send "Content-Length" header for 1xx/204/304 status codes. -CG
+
 Tue May 17 13:32:21 CEST 2016
        Allow clients to determine whether a connection is suspended;
        introduces MHD_CONNECTION_INFO_CONNECTION_SUSPENDED. -CG/FC

Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h      2016-06-01 20:00:51 UTC (rev 
37226)
+++ libmicrohttpd/src/include/microhttpd.h      2016-06-01 20:02:30 UTC (rev 
37227)
@@ -130,7 +130,7 @@
  * Current version of the library.
  * 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00094903
+#define MHD_VERSION 0x00094904
 
 /**
  * MHD-internal return code for "YES".

Modified: libmicrohttpd/src/microhttpd/connection.c
===================================================================
--- libmicrohttpd/src/microhttpd/connection.c   2016-06-01 20:00:51 UTC (rev 
37226)
+++ libmicrohttpd/src/microhttpd/connection.c   2016-06-01 20:02:30 UTC (rev 
37227)
@@ -876,9 +876,9 @@
       connection->write_buffer_size = 0;
       return MHD_YES;
     }
+  rc = connection->responseCode & (~MHD_ICY_FLAG);
   if (MHD_CONNECTION_FOOTERS_RECEIVED == connection->state)
     {
-      rc = connection->responseCode & (~MHD_ICY_FLAG);
       reason_phrase = MHD_get_reason_phrase_for (rc);
       sprintf (code,
                "%s %u %s\r\n",
@@ -988,7 +988,13 @@
       have_content_length = MHD_get_response_header (connection->response,
                                                      
MHD_HTTP_HEADER_CONTENT_LENGTH);
 
+      /* MHD_HTTP_NO_CONTENT, MHD_HTTP_NOT_MODIFIED and 1xx-status
+         codes SHOULD NOT have a Content-Length according to spec;
+         also chunked encoding / unknown length or CONNECT... */
       if ( (MHD_SIZE_UNKNOWN != connection->response->total_size) &&
+           (MHD_HTTP_NO_CONTENT != rc) &&
+           (MHD_HTTP_NOT_MODIFIED != rc) &&
+           (MHD_HTTP_OK < rc) &&
            (NULL == have_content_length) &&
            ( (NULL == connection->method) ||
              (! MHD_str_equal_caseless_ (connection->method,
@@ -3101,11 +3107,15 @@
   MHD_increment_response_rc (response);
   connection->response = response;
   connection->responseCode = status_code;
-  if ( (NULL != connection->method) &&
-       (MHD_str_equal_caseless_ (connection->method, MHD_HTTP_METHOD_HEAD)) )
+  if ( ( (NULL != connection->method) &&
+         (MHD_str_equal_caseless_ (connection->method, MHD_HTTP_METHOD_HEAD)) 
) ||
+       (MHD_HTTP_OK > status_code) ||
+       (MHD_HTTP_NO_CONTENT == status_code) ||
+       (MHD_HTTP_NOT_MODIFIED == status_code) )
     {
-      /* if this is a "HEAD" request, pretend that we
-         have already sent the full message body */
+      /* if this is a "HEAD" request, or a status code for
+         which a body is not allowed, pretend that we
+         have already sent the full message body. */
       connection->response_write_position = response->total_size;
     }
   if ( (MHD_CONNECTION_HEADERS_PROCESSED == connection->state) &&




reply via email to

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