diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-11-08 14:53:19 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-11-08 14:53:19 +0100 |
commit | 10bdf39505cf525b95886c140b3c2e82e7427d29 (patch) | |
tree | 03aec14ac7204ed93ce286770c180fcbae8c2c8a | |
parent | 3fc686e335437ec5f6d6270c8d713e9a01da966f (diff) | |
download | libmicrohttpd-10bdf39505cf525b95886c140b3c2e82e7427d29.tar.gz libmicrohttpd-10bdf39505cf525b95886c140b3c2e82e7427d29.zip |
add MHD_create_response_from_buffer_with_free_callback
-rw-r--r-- | doc/libmicrohttpd.texi | 18 | ||||
-rw-r--r-- | src/include/microhttpd.h | 18 | ||||
-rw-r--r-- | src/microhttpd/response.c | 28 |
3 files changed, 64 insertions, 0 deletions
diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi index 2ecb64e6..d87dac76 100644 --- a/doc/libmicrohttpd.texi +++ b/doc/libmicrohttpd.texi | |||
@@ -2020,6 +2020,24 @@ Return @code{NULL} on error (i.e. invalid arguments, out of memory). | |||
2020 | @end deftypefun | 2020 | @end deftypefun |
2021 | 2021 | ||
2022 | 2022 | ||
2023 | @deftypefun {struct MHD_Response *} MHD_create_response_from_buffer_with_free_callback (size_t size, void *data, MHD_ContentReaderFreeCallback crfc) | ||
2024 | Create a response object. The buffer at the end must be free'd | ||
2025 | by calling the @var{crfc} function. | ||
2026 | |||
2027 | @table @var | ||
2028 | @item size | ||
2029 | size of the data portion of the response; | ||
2030 | |||
2031 | @item buffer | ||
2032 | the data itself; | ||
2033 | |||
2034 | @item crfc | ||
2035 | function to call at the end to free memory allocated at @var{buffer}. | ||
2036 | @end table | ||
2037 | |||
2038 | Return @code{NULL} on error (i.e. invalid arguments, out of memory). | ||
2039 | @end deftypefun | ||
2040 | |||
2023 | @deftypefun {struct MHD_Response *} MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy) | 2041 | @deftypefun {struct MHD_Response *} MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy) |
2024 | Create a response object. The response object can be extended with | 2042 | Create a response object. The response object can be extended with |
2025 | header information and then it can be used any number of times. | 2043 | header information and then it can be used any number of times. |
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index 70ecd6e9..f8ec0122 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -2763,6 +2763,24 @@ MHD_create_response_from_buffer (size_t size, | |||
2763 | enum MHD_ResponseMemoryMode mode); | 2763 | enum MHD_ResponseMemoryMode mode); |
2764 | 2764 | ||
2765 | 2765 | ||
2766 | |||
2767 | |||
2768 | /** | ||
2769 | * Create a response object. The response object can be extended with | ||
2770 | * header information and then be used any number of times. | ||
2771 | * | ||
2772 | * @param size size of the data portion of the response | ||
2773 | * @param buffer size bytes containing the response's data portion | ||
2774 | * @param crfc function to call to free the @a buffer | ||
2775 | * @return NULL on error (i.e. invalid arguments, out of memory) | ||
2776 | * @ingroup response | ||
2777 | */ | ||
2778 | _MHD_EXTERN struct MHD_Response * | ||
2779 | MHD_create_response_from_buffer_with_free_callback (size_t size, | ||
2780 | void *buffer, | ||
2781 | MHD_ContentReaderFreeCallback crfc); | ||
2782 | |||
2783 | |||
2766 | /** | 2784 | /** |
2767 | * Create a response object. The response object can be extended with | 2785 | * Create a response object. The response object can be extended with |
2768 | * header information and then be used any number of times. | 2786 | * header information and then be used any number of times. |
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index d7835c20..08b7805d 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -701,6 +701,34 @@ MHD_create_response_from_buffer (size_t size, | |||
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | /** | ||
705 | * Create a response object. The response object can be extended with | ||
706 | * header information and then be used any number of times. | ||
707 | * | ||
708 | * @param size size of the data portion of the response | ||
709 | * @param buffer size bytes containing the response's data portion | ||
710 | * @param crfc function to call to free the @a buffer | ||
711 | * @return NULL on error (i.e. invalid arguments, out of memory) | ||
712 | * @ingroup response | ||
713 | */ | ||
714 | _MHD_EXTERN struct MHD_Response * | ||
715 | MHD_create_response_from_buffer_with_free_callback (size_t size, | ||
716 | void *buffer, | ||
717 | MHD_ContentReaderFreeCallback crfc) | ||
718 | { | ||
719 | struct MHD_Response *r; | ||
720 | |||
721 | r = MHD_create_response_from_data (size, | ||
722 | buffer, | ||
723 | GNUNET_YES, | ||
724 | GNUNET_NO); | ||
725 | if (NULL == r) | ||
726 | return r; | ||
727 | r->crfc = crfc; | ||
728 | return r; | ||
729 | } | ||
730 | |||
731 | |||
704 | #ifdef UPGRADE_SUPPORT | 732 | #ifdef UPGRADE_SUPPORT |
705 | /** | 733 | /** |
706 | * This connection-specific callback is provided by MHD to | 734 | * This connection-specific callback is provided by MHD to |