gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] branch master updated (41f35bbc -> b452fc4b)


From: gnunet
Subject: [libmicrohttpd] branch master updated (41f35bbc -> b452fc4b)
Date: Sat, 19 Mar 2022 11:52:41 +0100

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

karlson2k pushed a change to branch master
in repository libmicrohttpd.

    from 41f35bbc Added MHD_RF_HEAD_ONLY_RESPONSE response flag
     new 90b00e6f Updated doxy for some of the MHD_create_response_*() functions
     new 76ffb86c MHD_create_response_from_iovec(): fixed formatting
     new b452fc4b MHD_create_response_empty(): added new function

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/include/microhttpd.h  | 39 +++++++++++++++++++++++----
 src/microhttpd/response.c | 68 ++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 89 insertions(+), 18 deletions(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index fd9ddaba..e0351159 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 0x00097502
+#define MHD_VERSION 0x00097503
 
 /* If generic headers don't work on your platform, include headers
    which define 'va_list', 'size_t', 'ssize_t', 'intptr_t',
@@ -3425,8 +3425,13 @@ MHD_set_response_options (struct MHD_Response *response,
 
 
 /**
- * Create a response object.  The response object can be extended with
- * header information and then be used any number of times.
+ * Create a response object.
+ * The response object can be extended with header information and then be used
+ * any number of times.
+ *
+ * If response object is used to answer HEAD request then the body of the
+ * response is not used, while all headers (including automatic headers) are
+ * used.
  *
  * @param size size of the data portion of the response, #MHD_SIZE_UNKNOWN for 
unknown
  * @param block_size preferred block size for querying crc (advisory only,
@@ -3448,8 +3453,13 @@ MHD_create_response_from_callback (uint64_t size,
 
 
 /**
- * Create a response object.  The response object can be extended with
- * header information and then be used any number of times.
+ * Create a response object.
+ * The response object can be extended with header information and then be used
+ * any number of times.
+ *
+ * If response object is used to answer HEAD request then the body of the
+ * response is not used, while all headers (including automatic headers) are
+ * used.
  *
  * @param size size of the @a data portion of the response
  * @param data the data itself
@@ -3749,6 +3759,25 @@ MHD_create_response_from_iovec (const struct MHD_IoVec 
*iov,
                                 void *cls);
 
 
+/**
+ * Create a response object with empty (zero size) body.
+ *
+ * The response object can be extended with header information and then be used
+ * any number of times.
+ *
+ * This function is a faster equivalent of #MHD_create_response_from_buffer 
call
+ * with zero size combined with call of #MHD_set_response_options.
+ *
+ * @param flags the flags for the new response object
+ * @return NULL on error (i.e. invalid arguments, out of memory),
+ *         the pointer to the created response object otherwise
+ * @note Available since #MHD_VERSION 0x00097503
+ * @ingroup response
+ */
+_MHD_EXTERN struct MHD_Response *
+MHD_create_response_empty (enum MHD_ResponseFlags flags);
+
+
 /**
  * Enumeration for actions MHD should perform on the underlying socket
  * of the upgrade.  This API is not finalized, and in particular
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index 3803da2b..c604e14e 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -836,8 +836,13 @@ MHD_check_response_header_token_ci (const struct 
MHD_Response *response,
 
 
 /**
- * Create a response object.  The response object can be extended with
- * header information and then be used any number of times.
+ * Create a response object.
+ * The response object can be extended with header information and then be used
+ * any number of times.
+ *
+ * If response object is used to answer HEAD request then the body of the
+ * response is not used, while all headers (including automatic headers) are
+ * used.
  *
  * @param size size of the data portion of the response, #MHD_SIZE_UNKNOWN for 
unknown
  * @param block_size preferred block size for querying crc (advisory only,
@@ -1267,21 +1272,19 @@ MHD_create_response_from_fd64 (uint64_t size,
 
 
 /**
- * Create a response object with the content of provided buffer used as
- * the response body.
+ * Create a response object.
+ * The response object can be extended with header information and then be used
+ * any number of times.
  *
- * The response object can be extended with header information and then
- * be used any number of times.
- *
- * If response object is used to answer HEAD request then the body
- * of the response is not used, while all headers (including automatic
- * headers) are used.
+ * If response object is used to answer HEAD request then the body of the
+ * response is not used, while all headers (including automatic headers) are
+ * used.
  *
  * @param size size of the @a data portion of the response
  * @param data the data itself
  * @param must_free libmicrohttpd should free data when done
  * @param must_copy libmicrohttpd must make a copy of @a data
- *        right away, the data maybe released anytime after
+ *        right away, the data may be released anytime after
  *        this call returns
  * @return NULL on error (i.e. invalid arguments, out of memory)
  * @deprecated use #MHD_create_response_from_buffer instead
@@ -1546,7 +1549,8 @@ MHD_create_response_from_iovec (const struct MHD_IoVec 
*iov,
     return response;
   }
   mhd_assert (1 < i_cp);
-  {
+  if (1)
+  { /* for local variables local scope only */
     MHD_iovec_ *iov_copy;
     int num_copy_elements = i_cp;
 
@@ -1583,8 +1587,46 @@ MHD_create_response_from_iovec (const struct MHD_IoVec 
*iov,
     mhd_assert (num_copy_elements == i_cp);
     response->data_iov = iov_copy;
     response->data_iovcnt = i_cp;
-    return response;
   }
+  return response;
+}
+
+
+/**
+ * Create a response object with empty (zero size) body.
+ *
+ * The response object can be extended with header information and then be used
+ * any number of times.
+ *
+ * This function is a faster equivalent of #MHD_create_response_from_buffer 
call
+ * with zero size combined with call of #MHD_set_response_options.
+ *
+ * @param flags the flags for the new response object
+ * @return NULL on error (i.e. invalid arguments, out of memory),
+ *         the pointer to the created response object otherwise
+ * @note Available since #MHD_VERSION 0x00097503
+ * @ingroup response
+ */
+struct MHD_Response *
+MHD_create_response_empty (enum MHD_ResponseFlags flags)
+{
+  struct MHD_Response *r;
+  r = (struct MHD_Response *) MHD_calloc_ (1, sizeof (struct MHD_Response));
+  if (NULL != r)
+  {
+    if (! MHD_mutex_init_ (&r->mutex))
+    {
+      r->fd = -1;
+      r->reference_count = 1;
+      /* If any flags combination will be not allowed, replace the next
+       * assignment with MHD_set_response_options() call. */
+      r->flags = flags;
+
+      return r; /* Successful result */
+    }
+    free (r);
+  }
+  return NULL; /* Something failed */
 }
 
 

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