gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r33603 - in libmicrohttpd: . doc src/include src/microhttpd
Date: Sun, 8 Jun 2014 15:11:50 +0200

Author: grothoff
Date: 2014-06-08 15:11:50 +0200 (Sun, 08 Jun 2014)
New Revision: 33603

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/doc/libmicrohttpd.texi
   libmicrohttpd/src/include/microhttpd.h
   libmicrohttpd/src/include/platform_interface.h
   libmicrohttpd/src/include/w32functions.h
   libmicrohttpd/src/microhttpd/connection.c
   libmicrohttpd/src/microhttpd/internal.c
   libmicrohttpd/src/microhttpd/internal.h
   libmicrohttpd/src/microhttpd/response.c
Log:
adding MHD_set_response_options function

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2014-06-08 12:23:21 UTC (rev 33602)
+++ libmicrohttpd/ChangeLog     2014-06-08 13:11:50 UTC (rev 33603)
@@ -1,3 +1,9 @@
+Sun Jun  8 15:10:44 CEST 2014
+       Add 'MHD_set_response_options' as a way to set per-response
+       flags.  Add flag to force HTTP 1.0-only conservative
+       behavior, in particular suppressing adding "Connection"
+       headers. -CG
+
 Mon Jun  2 00:03:28 CEST 2014
        Added back unescaping for URI path (#3413) but without
        unescaping '+' (#3371) to remain compatible with

Modified: libmicrohttpd/doc/libmicrohttpd.texi
===================================================================
--- libmicrohttpd/doc/libmicrohttpd.texi        2014-06-08 12:23:21 UTC (rev 
33602)
+++ libmicrohttpd/doc/libmicrohttpd.texi        2014-06-08 13:11:50 UTC (rev 
33603)
@@ -958,8 +958,35 @@
 @end deftp
 
 
address@hidden {Enumeration} MHD_ResponseFlags
+Response-specific flags.  Passed as an argument to
address@hidden()}.
 
address@hidden @code
address@hidden MHD_RF_NONE
+No special handling.
 
address@hidden MHD_RF_HTTP_VERSION_1_0_ONLY
+Only respond in conservative HTTP 1.0-mode.   In particular,
+do not (automatically) sent "Connection" headers and always
+close the connection after generating the response.
+
address@hidden table
address@hidden deftp
+
+
address@hidden {Enumeration} MHD_ResponseOptions
+Response-specific options.  Passed in the varargs portion of
address@hidden()}.
+
address@hidden @code
address@hidden MHD_RO_END
+No more options / last option.  This is used to terminate the VARARGs
+list.
address@hidden table
address@hidden deftp
+
+
 @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 @c ------------------------------------------------------------
@@ -1559,6 +1586,7 @@
 * microhttpd-response enqueue:: Enqueuing a response.
 * microhttpd-response create::  Creating a response object.
 * microhttpd-response headers:: Adding headers to a response.
+* microhttpd-response options:: Setting response options.
 * microhttpd-response inspect:: Inspecting a response object.
 @end menu
 
@@ -1852,6 +1880,34 @@
 @end deftypefun
 
 
address@hidden ------------------------------------------------------------
address@hidden microhttpd-response options
address@hidden Setting response options
+
+
address@hidden int MHD_set_response_options (struct MHD_Response *response, 
enum MHD_ResponseFlags flags, ...)
+Set special flags and options for a response.
+
+Calling this functions sets the given flags and options for the response.
+
address@hidden @var
address@hidden response
+which response should be modified;
+
address@hidden flags
+flags to set for the response;
+
address@hidden table
+
+Additional arguments are a list of options (type-value pairs,
+terminated with @code{MHD_RO_END}). It is mandatory to use
address@hidden as last argument, even when there are no
+additional arguments.
+
+Return @code{MHD_NO} on error, @code{MHD_YES} on success.
address@hidden deftypefun
+
+
 @c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 @c ------------------------------------------------------------

Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h      2014-06-08 12:23:21 UTC (rev 
33602)
+++ libmicrohttpd/src/include/microhttpd.h      2014-06-08 13:11:50 UTC (rev 
33603)
@@ -130,7 +130,7 @@
  * Current version of the library.
  * 0x01093001 = 1.9.30-1.
  */
-#define MHD_VERSION 0x00093700
+#define MHD_VERSION 0x00093701
 
 /**
  * MHD-internal return code for "YES".
@@ -1745,7 +1745,54 @@
 
 /* **************** Response manipulation functions ***************** */
 
+
 /**
+ * Flags for special handling of responses.
+ */
+enum MHD_ResponseFlags
+{
+  /**
+   * Default: no special flags.
+   */
+  MHD_RF_NONE = 0,
+
+  /**
+   * Only respond in conservative HTTP 1.0-mode.   In particular,
+   * do not (automatically) sent "Connection" headers and always
+   * close the connection after generating the response.
+   */
+  MHD_RF_HTTP_VERSION_1_0_ONLY = 1
+
+};
+
+
+/**
+ * MHD options (for future extensions).
+ */
+enum MHD_ResponseOptions
+{
+  /**
+   * End of the list of options.
+   */
+  MHD_RO_END = 0
+};
+
+
+/**
+ * Set special flags and options for a response.
+ *
+ * @param response the response to modify
+ * @param flags to set for the response
+ * @param ... #MHD_RO_END terminated list of options
+ * @return #MHD_YES on success, #MHD_NO on error
+ */
+int
+MHD_set_response_options (struct MHD_Response *response,
+                          enum MHD_ResponseFlags flags,
+                          ...);
+
+
+/**
  * Create a response object.  The response object can be extended with
  * header information and then be used any number of times.
  *

Modified: libmicrohttpd/src/include/platform_interface.h
===================================================================
--- libmicrohttpd/src/include/platform_interface.h      2014-06-08 12:23:21 UTC 
(rev 33602)
+++ libmicrohttpd/src/include/platform_interface.h      2014-06-08 13:11:50 UTC 
(rev 33603)
@@ -13,12 +13,12 @@
   Lesser General Public License for more details.
 
   You should have received a copy of the GNU Lesser General Public
-  License along with this library. 
+  License along with this library.
   If not, see <http://www.gnu.org/licenses/>.
 */
 
 /**
- * @file include/platfrom_interface.h
+ * @file include/platform_interface.h
  * @brief  internal platform abstraction functions
  * @author Karlson2k (Evgeny Grin)
  */

Modified: libmicrohttpd/src/include/w32functions.h
===================================================================
--- libmicrohttpd/src/include/w32functions.h    2014-06-08 12:23:21 UTC (rev 
33602)
+++ libmicrohttpd/src/include/w32functions.h    2014-06-08 13:11:50 UTC (rev 
33603)
@@ -13,12 +13,12 @@
   Lesser General Public License for more details.
 
   You should have received a copy of the GNU Lesser General Public
-  License along with this library. 
+  License along with this library.
   If not, see <http://www.gnu.org/licenses/>.
 */
 
 /**
- * @file platform/w32functions.h
+ * @file include/w32functions.h
  * @brief  internal functions for W32 systems
  * @author Karlson2k (Evgeny Grin)
  */

Modified: libmicrohttpd/src/microhttpd/connection.c
===================================================================
--- libmicrohttpd/src/microhttpd/connection.c   2014-06-08 12:23:21 UTC (rev 
33602)
+++ libmicrohttpd/src/microhttpd/connection.c   2014-06-08 13:11:50 UTC (rev 
33603)
@@ -528,6 +528,9 @@
 
   if (NULL == connection->version)
     return MHD_NO;
+  if ( (NULL != connection->response) &&
+       (0 != (connection->response->flags & MHD_RF_HTTP_VERSION_1_0_ONLY) ) )
+    return MHD_NO;
   end = MHD_lookup_connection_value (connection,
                                      MHD_HEADER_KIND,
                                      MHD_HTTP_HEADER_CONNECTION);
@@ -596,6 +599,7 @@
          /* 'close' header doesn't exist yet, see if we need to add one;
             if the client asked for a close, no need to start chunk'ing */
           if ( (NULL == client_close) &&
+               (0 == (connection->response->flags & 
MHD_RF_HTTP_VERSION_1_0_ONLY) ) &&
                (MHD_YES == keepalive_possible (connection)) &&
                (0 == strcasecmp (connection->version,
                                  MHD_HTTP_VERSION_1_1)) )
@@ -662,13 +666,15 @@
                                   MHD_HTTP_HEADER_CONTENT_LENGTH, buf);
        }
     }
-  if (MHD_YES == add_close)
+  if ( (MHD_YES == add_close) &&
+       (0 == (connection->response->flags & MHD_RF_HTTP_VERSION_1_0_ONLY) ) )
     MHD_add_response_header (connection->response,
                             MHD_HTTP_HEADER_CONNECTION,
                              "close");
   if ( (NULL == have_keepalive) &&
        (NULL == have_close) &&
        (MHD_NO == add_close) &&
+       (0 == (connection->response->flags & MHD_RF_HTTP_VERSION_1_0_ONLY) ) &&
        (MHD_YES == keepalive_possible (connection)) )
     MHD_add_response_header (connection->response,
                             MHD_HTTP_HEADER_CONNECTION,

Modified: libmicrohttpd/src/microhttpd/internal.c
===================================================================
--- libmicrohttpd/src/microhttpd/internal.c     2014-06-08 12:23:21 UTC (rev 
33602)
+++ libmicrohttpd/src/microhttpd/internal.c     2014-06-08 13:11:50 UTC (rev 
33603)
@@ -160,6 +160,13 @@
 }
 
 
+/**
+ * Equivalent to time(NULL) but tries to use some sort of monotonic
+ * clock that isn't affected by someone setting the system real time
+ * clock.
+ *
+ * @return 'current' time
+ */
 time_t
 MHD_monotonic_time (void)
 {

Modified: libmicrohttpd/src/microhttpd/internal.h
===================================================================
--- libmicrohttpd/src/microhttpd/internal.h     2014-06-08 12:23:21 UTC (rev 
33602)
+++ libmicrohttpd/src/microhttpd/internal.h     2014-06-08 13:11:50 UTC (rev 
33603)
@@ -266,8 +266,8 @@
   char *data;
 
   /**
-   * Closure to give to the content reader
-   * free callback.
+   * Closure to give to the content reader @e crc
+   * and content reader free callback @crfc.
    */
   void *crc_cls;
 
@@ -284,8 +284,8 @@
   MHD_ContentReaderFreeCallback crfc;
 
   /**
-   * Mutex to synchronize access to data/size and
-   * reference counts.
+   * Mutex to synchronize access to @e data, @e size and
+   * @e reference_count.
    */
   MHD_mutex_ mutex;
 
@@ -296,22 +296,23 @@
 
   /**
    * At what offset in the stream is the
-   * beginning of data located?
+   * beginning of @e data located?
    */
   uint64_t data_start;
 
   /**
-   * Offset to start reading from when using 'fd'.
+   * Offset to start reading from when using @e fd.
    */
   off_t fd_off;
 
   /**
-   * Size of data.
+   * Number of bytes ready in @e data (buffer may be larger
+   * than what is filled with payload).
    */
   size_t data_size;
 
   /**
-   * Size of the data buffer.
+   * Size of the data buffer @e data.
    */
   size_t data_buffer_size;
 
@@ -326,6 +327,11 @@
    */
   int fd;
 
+  /**
+   * Flags set for the MHD response.
+   */
+  enum MHD_ResponseFlags flags;
+
 };
 
 
@@ -1386,6 +1392,7 @@
  *
  * @return 'current' time
  */
-time_t MHD_monotonic_time(void);
+time_t
+MHD_monotonic_time(void);
 
 #endif

Modified: libmicrohttpd/src/microhttpd/response.c
===================================================================
--- libmicrohttpd/src/microhttpd/response.c     2014-06-08 12:23:21 UTC (rev 
33602)
+++ libmicrohttpd/src/microhttpd/response.c     2014-06-08 13:11:50 UTC (rev 
33603)
@@ -266,6 +266,40 @@
 
 
 /**
+ * Set special flags and options for a response.
+ *
+ * @param response the response to modify
+ * @param flags to set for the response
+ * @param ... #MHD_RO_END terminated list of options
+ * @return #MHD_YES on success, #MHD_NO on error
+ */
+int
+MHD_set_response_options (struct MHD_Response *response,
+                          enum MHD_ResponseFlags flags,
+                          ...)
+{
+  va_list ap;
+  int ret;
+  enum MHD_ResponseOptions ro;
+
+  ret = MHD_YES;
+  response->flags = flags;
+  va_start (ap, flags);
+  while (MHD_RO_END != (ro = va_arg (ap, enum MHD_ResponseOptions)))
+  {
+    switch (ro)
+    {
+    default:
+      ret = MHD_NO;
+      break;
+    }
+  }
+  va_end (ap);
+  return ret;
+}
+
+
+/**
  * Given a file descriptor, read data from the file
  * to generate the response.
  *




reply via email to

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