aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-05-08 21:18:08 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-05-12 20:52:13 +0300
commit8a9a64a7034c5a8f55bccb9e1247ae26ee45669d (patch)
tree6a437b9657a5386a43539061c1f1eb28b4112067
parent9ac7492bb57e5545b7ca3d6f840b47b2b90c33a0 (diff)
downloadlibmicrohttpd-8a9a64a7034c5a8f55bccb9e1247ae26ee45669d.tar.gz
libmicrohttpd-8a9a64a7034c5a8f55bccb9e1247ae26ee45669d.zip
Added new response create function.
Added MHD_create_response_from_buffer_with_free_callback_cls function
-rw-r--r--src/include/microhttpd.h24
-rw-r--r--src/microhttpd/response.c32
2 files changed, 55 insertions, 1 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h
index 44156aab..4c9937bf 100644
--- a/src/include/microhttpd.h
+++ b/src/include/microhttpd.h
@@ -130,7 +130,7 @@ typedef intptr_t ssize_t;
130 * they are parsed as decimal numbers. 130 * they are parsed as decimal numbers.
131 * Example: 0x01093001 = 1.9.30-1. 131 * Example: 0x01093001 = 1.9.30-1.
132 */ 132 */
133#define MHD_VERSION 0x00097301 133#define MHD_VERSION 0x00097302
134 134
135/** 135/**
136 * Operational results from MHD calls. 136 * Operational results from MHD calls.
@@ -3242,6 +3242,28 @@ MHD_create_response_from_buffer_with_free_callback (size_t size,
3242 3242
3243 3243
3244/** 3244/**
3245 * Create a response object.
3246 * The response object can be extended with header information and then be
3247 * used any number of times.
3248 *
3249 * @param size size of the data portion of the response
3250 * @param buffer size bytes containing the response's data portion
3251 * @param crfc function to call to cleanup, if set to NULL then callback
3252 * is not called
3253 * @param crfc_cls an argument for @a crfc
3254 * @return NULL on error (i.e. invalid arguments, out of memory)
3255 * @note Available since #MHD_VERSION 0x00097302
3256 * @ingroup response
3257 */
3258_MHD_EXTERN struct MHD_Response *
3259MHD_create_response_from_buffer_with_free_callback_cls (size_t size,
3260 void *buffer,
3261 MHD_ContentReaderFreeCallback
3262 crfc,
3263 void *crfc_cls);
3264
3265
3266/**
3245 * Create a response object. The response object can be extended with 3267 * Create a response object. The response object can be extended with
3246 * header information and then be used any number of times. 3268 * header information and then be used any number of times.
3247 * 3269 *
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c
index cc0cd38b..bf78d735 100644
--- a/src/microhttpd/response.c
+++ b/src/microhttpd/response.c
@@ -848,6 +848,38 @@ MHD_create_response_from_buffer_with_free_callback (size_t size,
848 848
849 849
850/** 850/**
851 * Create a response object.
852 * The response object can be extended with header information and then be
853 * used any number of times.
854 *
855 * @param size size of the data portion of the response
856 * @param buffer size bytes containing the response's data portion
857 * @param crfc function to call to cleanup, if set to NULL then callback
858 * is not called
859 * @param crfc_cls an argument for @a crfc
860 * @return NULL on error (i.e. invalid arguments, out of memory)
861 * @note Available since #MHD_VERSION 0x00097302
862 * @ingroup response
863 */
864_MHD_EXTERN struct MHD_Response *
865MHD_create_response_from_buffer_with_free_callback_cls (size_t size,
866 void *buffer,
867 MHD_ContentReaderFreeCallback
868 crfc,
869 void *crfc_cls)
870{
871 struct MHD_Response *r;
872
873 r = MHD_create_response_from_buffer_with_free_callback (size,
874 buffer,
875 crfc);
876 if (NULL != r)
877 r->crc_cls = crfc_cls;
878 return r;
879}
880
881
882/**
851 * Create a response object from an array of memory buffers. 883 * Create a response object from an array of memory buffers.
852 * The response object can be extended with header information and then be used 884 * The response object can be extended with header information and then be used
853 * any number of times. 885 * any number of times.