aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-03-19 13:44:19 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-03-19 13:51:41 +0300
commitb452fc4b19e70f796147ca02349e5ec07afde738 (patch)
tree1c95626a44620c527cce0b571d0735dad63d6ff0 /src
parent76ffb86c041863944e299d66e0e827de18287910 (diff)
downloadlibmicrohttpd-b452fc4b19e70f796147ca02349e5ec07afde738.tar.gz
libmicrohttpd-b452fc4b19e70f796147ca02349e5ec07afde738.zip
MHD_create_response_empty(): added new function
Diffstat (limited to 'src')
-rw-r--r--src/include/microhttpd.h21
-rw-r--r--src/microhttpd/response.c38
2 files changed, 58 insertions, 1 deletions
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"
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 0x00097502 99#define MHD_VERSION 0x00097503
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',
@@ -3760,6 +3760,25 @@ MHD_create_response_from_iovec (const struct MHD_IoVec *iov,
3760 3760
3761 3761
3762/** 3762/**
3763 * Create a response object with empty (zero size) body.
3764 *
3765 * The response object can be extended with header information and then be used
3766 * any number of times.
3767 *
3768 * This function is a faster equivalent of #MHD_create_response_from_buffer call
3769 * with zero size combined with call of #MHD_set_response_options.
3770 *
3771 * @param flags the flags for the new response object
3772 * @return NULL on error (i.e. invalid arguments, out of memory),
3773 * the pointer to the created response object otherwise
3774 * @note Available since #MHD_VERSION 0x00097503
3775 * @ingroup response
3776 */
3777_MHD_EXTERN struct MHD_Response *
3778MHD_create_response_empty (enum MHD_ResponseFlags flags);
3779
3780
3781/**
3763 * Enumeration for actions MHD should perform on the underlying socket 3782 * Enumeration for actions MHD should perform on the underlying socket
3764 * of the upgrade. This API is not finalized, and in particular 3783 * of the upgrade. This API is not finalized, and in particular
3765 * the final set of actions is yet to be decided. This is just an 3784 * the final set of actions is yet to be decided. This is just an
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,
1592} 1592}
1593 1593
1594 1594
1595/**
1596 * Create a response object with empty (zero size) body.
1597 *
1598 * The response object can be extended with header information and then be used
1599 * any number of times.
1600 *
1601 * This function is a faster equivalent of #MHD_create_response_from_buffer call
1602 * with zero size combined with call of #MHD_set_response_options.
1603 *
1604 * @param flags the flags for the new response object
1605 * @return NULL on error (i.e. invalid arguments, out of memory),
1606 * the pointer to the created response object otherwise
1607 * @note Available since #MHD_VERSION 0x00097503
1608 * @ingroup response
1609 */
1610struct MHD_Response *
1611MHD_create_response_empty (enum MHD_ResponseFlags flags)
1612{
1613 struct MHD_Response *r;
1614 r = (struct MHD_Response *) MHD_calloc_ (1, sizeof (struct MHD_Response));
1615 if (NULL != r)
1616 {
1617 if (! MHD_mutex_init_ (&r->mutex))
1618 {
1619 r->fd = -1;
1620 r->reference_count = 1;
1621 /* If any flags combination will be not allowed, replace the next
1622 * assignment with MHD_set_response_options() call. */
1623 r->flags = flags;
1624
1625 return r; /* Successful result */
1626 }
1627 free (r);
1628 }
1629 return NULL; /* Something failed */
1630}
1631
1632
1595#ifdef UPGRADE_SUPPORT 1633#ifdef UPGRADE_SUPPORT
1596/** 1634/**
1597 * This connection-specific callback is provided by MHD to 1635 * This connection-specific callback is provided by MHD to