gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r25703 - in libmicrohttpd: . src/daemon


From: gnunet
Subject: [GNUnet-SVN] r25703 - in libmicrohttpd: . src/daemon
Date: Sun, 6 Jan 2013 21:21:31 +0100

Author: grothoff
Date: 2013-01-06 21:21:31 +0100 (Sun, 06 Jan 2013)
New Revision: 25703

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/daemon/connection.c
Log:
allow 0-byte responses with response_from_callback

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2013-01-06 00:13:33 UTC (rev 25702)
+++ libmicrohttpd/ChangeLog     2013-01-06 20:21:31 UTC (rev 25703)
@@ -1,3 +1,7 @@
+Sun Jan  6 21:10:13 CET 2013
+       Enable use of "MHD_create_response_from_callback" with
+       body size of zeor. -CG
+
 Tue Dec 25 16:16:30 CET 2012
        Releasing libmicrohttpd 0.9.24. -CG
 

Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c       2013-01-06 00:13:33 UTC (rev 
25702)
+++ libmicrohttpd/src/daemon/connection.c       2013-01-06 20:21:31 UTC (rev 
25703)
@@ -370,6 +370,8 @@
   response = connection->response;
   if (NULL == response->crc)
     return MHD_YES;
+  if (0 == response->data_size)
+    return MHD_YES; /* 0-byte response is always ready */
   if ( (response->data_start <=
        connection->response_write_position) &&
        (response->data_size + response->data_start >
@@ -477,10 +479,13 @@
   else
     {
       /* buffer not in range, try to fill it */
-      ret = response->crc (response->crc_cls,
-                          connection->response_write_position,
-                          &connection->write_buffer[sizeof (cbuf)],
-                          connection->write_buffer_size - sizeof (cbuf) - 2);
+      if (0 == response->data_size)
+       ret = 0; /* response must be empty, don't bother calling crc */
+      else
+       ret = response->crc (response->crc_cls,
+                            connection->response_write_position,
+                            &connection->write_buffer[sizeof (cbuf)],
+                            connection->write_buffer_size - sizeof (cbuf) - 2);
     }
   if (MHD_CONTENT_READER_END_WITH_ERROR == ret)
     {
@@ -490,7 +495,8 @@
                              "Closing connection (error generating 
response)\n");
       return MHD_NO;
     }
-  if (MHD_CONTENT_READER_END_OF_STREAM == ret) 
+  if ( (MHD_CONTENT_READER_END_OF_STREAM == ret) ||
+       (0 == response->data_size) )
     {
       /* end of message, signal other side! */
       strcpy (connection->write_buffer, "0\r\n");
@@ -499,7 +505,7 @@
       response->total_size = connection->response_write_position;
       return MHD_YES;
     }
-  if (0 == ret)
+  if (0 == ret) 
     {
       connection->state = MHD_CONNECTION_CHUNKED_BODY_UNREADY;
       return MHD_NO;




reply via email to

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