gnunet-svn
[Top][All Lists]
Advanced

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

[libmicrohttpd] 03/03: MHD_create_response_empty(): added new function


From: gnunet
Subject: [libmicrohttpd] 03/03: MHD_create_response_empty(): added new function
Date: Sat, 19 Mar 2022 11:52:44 +0100

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

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit b452fc4b19e70f796147ca02349e5ec07afde738
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Mar 19 13:44:19 2022 +0300

    MHD_create_response_empty(): added new function
---
 src/include/microhttpd.h  | 21 ++++++++++++++++++++-
 src/microhttpd/response.c | 38 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 087a7d96..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',
@@ -3759,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 64d33c15..c604e14e 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -1592,6 +1592,44 @@ MHD_create_response_from_iovec (const struct MHD_IoVec 
*iov,
 }
 
 
+/**
+ * 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 */
+}
+
+
 #ifdef UPGRADE_SUPPORT
 /**
  * This connection-specific callback is provided by MHD to

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