libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 8a9a64a7034c5a8f55bccb9e1247ae26ee45669d
parent 9ac7492bb57e5545b7ca3d6f840b47b2b90c33a0
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sat,  8 May 2021 21:18:08 +0300

Added new response create function.

Added MHD_create_response_from_buffer_with_free_callback_cls function

Diffstat:
Msrc/include/microhttpd.h | 24+++++++++++++++++++++++-
Msrc/microhttpd/response.c | 32++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -130,7 +130,7 @@ typedef intptr_t ssize_t; * they are parsed as decimal numbers. * Example: 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00097301 +#define MHD_VERSION 0x00097302 /** * Operational results from MHD calls. @@ -3242,6 +3242,28 @@ MHD_create_response_from_buffer_with_free_callback (size_t size, /** + * Create a response object. + * The response object can be extended with header information and then be + * used any number of times. + * + * @param size size of the data portion of the response + * @param buffer size bytes containing the response's data portion + * @param crfc function to call to cleanup, if set to NULL then callback + * is not called + * @param crfc_cls an argument for @a crfc + * @return NULL on error (i.e. invalid arguments, out of memory) + * @note Available since #MHD_VERSION 0x00097302 + * @ingroup response + */ +_MHD_EXTERN struct MHD_Response * +MHD_create_response_from_buffer_with_free_callback_cls (size_t size, + void *buffer, + MHD_ContentReaderFreeCallback + crfc, + void *crfc_cls); + + +/** * Create a response object. The response object can be extended with * header information and then be used any number of times. * diff --git 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, /** + * Create a response object. + * The response object can be extended with header information and then be + * used any number of times. + * + * @param size size of the data portion of the response + * @param buffer size bytes containing the response's data portion + * @param crfc function to call to cleanup, if set to NULL then callback + * is not called + * @param crfc_cls an argument for @a crfc + * @return NULL on error (i.e. invalid arguments, out of memory) + * @note Available since #MHD_VERSION 0x00097302 + * @ingroup response + */ +_MHD_EXTERN struct MHD_Response * +MHD_create_response_from_buffer_with_free_callback_cls (size_t size, + void *buffer, + MHD_ContentReaderFreeCallback + crfc, + void *crfc_cls) +{ + struct MHD_Response *r; + + r = MHD_create_response_from_buffer_with_free_callback (size, + buffer, + crfc); + if (NULL != r) + r->crc_cls = crfc_cls; + return r; +} + + +/** * Create a response object from an array of memory buffers. * The response object can be extended with header information and then be used * any number of times.