aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-04-18 11:17:45 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-04-19 18:55:26 +0300
commitd3ae3c432d1d83bf5d300ca4670aa2626c574496 (patch)
treea97c5fb68af3c1545eb27f02fbad6d3c3ccf9adf
parentf71019f00b1d4b31b01dac2f98b46040cdd67b7e (diff)
downloadlibmicrohttpd-d3ae3c432d1d83bf5d300ca4670aa2626c574496.tar.gz
libmicrohttpd-d3ae3c432d1d83bf5d300ca4670aa2626c574496.zip
Added new API function MHD_create_response_from_buffer_static()
-rw-r--r--src/include/microhttpd.h28
-rw-r--r--src/microhttpd/response.c32
2 files changed, 59 insertions, 1 deletions
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"
96 * they are parsed as decimal numbers. 96 * they are parsed as decimal numbers.
97 * Example: 0x01093001 = 1.9.30-1. 97 * Example: 0x01093001 = 1.9.30-1.
98 */ 98 */
99#define MHD_VERSION 0x00097505 99#define MHD_VERSION 0x00097506
100 100
101/* If generic headers don't work on your platform, include headers 101/* If generic headers don't work on your platform, include headers
102 which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', 102 which define 'va_list', 'size_t', 'ssize_t', 'intptr_t',
@@ -3539,6 +3539,32 @@ MHD_create_response_from_buffer (size_t size,
3539 3539
3540 3540
3541/** 3541/**
3542 * Create a response object with the content of provided statically allocated
3543 * buffer used as the response body.
3544 *
3545 * The buffer must be valid for the lifetime of the response. The easiest way
3546 * to achieve this is to use a statically allocated buffer.
3547 *
3548 * The response object can be extended with header information and then
3549 * be used any number of times.
3550 *
3551 * If response object is used to answer HEAD request then the body
3552 * of the response is not used, while all headers (including automatic
3553 * headers) are used.
3554 *
3555 * @param size the size of the data in @a buffer, can be zero
3556 * @param buffer the buffer with the data for the response body, can be NULL
3557 * if @a size is zero
3558 * @return NULL on error (i.e. invalid arguments, out of memory)
3559 * @note Available since #MHD_VERSION 0x00097506
3560 * @ingroup response
3561 */
3562_MHD_EXTERN struct MHD_Response *
3563MHD_create_response_from_buffer_static (size_t size,
3564 const void *buffer);
3565
3566
3567/**
3542 * Create a response object with the content of provided buffer used as 3568 * Create a response object with the content of provided buffer used as
3543 * the response body. 3569 * the response body.
3544 * 3570 *
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
@@ -1379,6 +1379,38 @@ MHD_create_response_from_buffer (size_t size,
1379 1379
1380 1380
1381/** 1381/**
1382 * Create a response object with the content of provided statically allocated
1383 * buffer used as the response body.
1384 *
1385 * The buffer must be valid for the lifetime of the response. The easiest way
1386 * to achieve this is to use a statically allocated buffer.
1387 *
1388 * The response object can be extended with header information and then
1389 * be used any number of times.
1390 *
1391 * If response object is used to answer HEAD request then the body
1392 * of the response is not used, while all headers (including automatic
1393 * headers) are used.
1394 *
1395 * @param size the size of the data in @a buffer, can be zero
1396 * @param buffer the buffer with the data for the response body, can be NULL
1397 * if @a size is zero
1398 * @return NULL on error (i.e. invalid arguments, out of memory)
1399 * @note Available since #MHD_VERSION 0x00097506
1400 * @ingroup response
1401 */
1402_MHD_EXTERN struct MHD_Response *
1403MHD_create_response_from_buffer_static (size_t size,
1404 const void *buffer)
1405{
1406 return MHD_create_response_from_buffer_with_free_callback_cls (size,
1407 buffer,
1408 NULL,
1409 NULL);
1410}
1411
1412
1413/**
1382 * Create a response object with the content of provided buffer used as 1414 * Create a response object with the content of provided buffer used as
1383 * the response body. 1415 * the response body.
1384 * 1416 *