[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 06/14: Added new API function MHD_create_response_from_b
From: |
gnunet |
Subject: |
[libmicrohttpd] 06/14: Added new API function MHD_create_response_from_buffer_static() |
Date: |
Tue, 19 Apr 2022 19:31:13 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit d3ae3c432d1d83bf5d300ca4670aa2626c574496
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Apr 18 11:17:45 2022 +0300
Added new API function MHD_create_response_from_buffer_static()
---
src/include/microhttpd.h | 28 +++++++++++++++++++++++++++-
src/microhttpd/response.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 6d0eb4c8..8178584c 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 0x00097505
+#define MHD_VERSION 0x00097506
/* If generic headers don't work on your platform, include headers
which define 'va_list', 'size_t', 'ssize_t', 'intptr_t',
@@ -3538,6 +3538,32 @@ MHD_create_response_from_buffer (size_t size,
enum MHD_ResponseMemoryMode mode);
+/**
+ * Create a response object with the content of provided statically allocated
+ * buffer used as the response body.
+ *
+ * The buffer must be valid for the lifetime of the response. The easiest way
+ * to achieve this is to use a statically allocated buffer.
+ *
+ * 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 the size of the data in @a buffer, can be zero
+ * @param buffer the buffer with the data for the response body, can be NULL
+ * if @a size is zero
+ * @return NULL on error (i.e. invalid arguments, out of memory)
+ * @note Available since #MHD_VERSION 0x00097506
+ * @ingroup response
+ */
+_MHD_EXTERN struct MHD_Response *
+MHD_create_response_from_buffer_static (size_t size,
+ const void *buffer);
+
+
/**
* Create a response object with the content of provided buffer used as
* the response body.
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index b63db1e5..ef04f584 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -1378,6 +1378,38 @@ MHD_create_response_from_buffer (size_t size,
}
+/**
+ * Create a response object with the content of provided statically allocated
+ * buffer used as the response body.
+ *
+ * The buffer must be valid for the lifetime of the response. The easiest way
+ * to achieve this is to use a statically allocated buffer.
+ *
+ * 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 the size of the data in @a buffer, can be zero
+ * @param buffer the buffer with the data for the response body, can be NULL
+ * if @a size is zero
+ * @return NULL on error (i.e. invalid arguments, out of memory)
+ * @note Available since #MHD_VERSION 0x00097506
+ * @ingroup response
+ */
+_MHD_EXTERN struct MHD_Response *
+MHD_create_response_from_buffer_static (size_t size,
+ const void *buffer)
+{
+ return MHD_create_response_from_buffer_with_free_callback_cls (size,
+ buffer,
+ NULL,
+ NULL);
+}
+
+
/**
* Create a response object with the content of provided buffer used as
* the response body.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (03c29b63 -> 4b6419b1), gnunet, 2022/04/19
- [libmicrohttpd] 01/14: refactoring: use 'const' for response buffers, gnunet, 2022/04/19
- [libmicrohttpd] 04/14: microhttpd.h: removed empty line, gnunet, 2022/04/19
- [libmicrohttpd] 03/14: Refactored create response functions., gnunet, 2022/04/19
- [libmicrohttpd] 02/14: Added _MHD_EXTERN to the all public functions definitions, gnunet, 2022/04/19
- [libmicrohttpd] 06/14: Added new API function MHD_create_response_from_buffer_static(),
gnunet <=
- [libmicrohttpd] 07/14: Fixed drop of 'const' when building internal error response, gnunet, 2022/04/19
- [libmicrohttpd] 12/14: microhttpd.h: minor doxy improvement, gnunet, 2022/04/19
- [libmicrohttpd] 08/14: Fixed missing 'const' qualifiers, gnunet, 2022/04/19
- [libmicrohttpd] 05/14: MHD_get_version(): fixed signed value bit shift, gnunet, 2022/04/19
- [libmicrohttpd] 09/14: Added workaround for external APIs, gnunet, 2022/04/19
- [libmicrohttpd] 11/14: Added new API function MHD_create_response_from_buffer_copy(), gnunet, 2022/04/19
- [libmicrohttpd] 10/14: Minor simplification for ALPN protocols code, gnunet, 2022/04/19
- [libmicrohttpd] 14/14: doc/examples: Fixed drop of 'const' qualifiers, gnunet, 2022/04/19
- [libmicrohttpd] 13/14: src/examples: Fixed drop of 'const' qualifiers and minor fixes., gnunet, 2022/04/19