diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-07-22 11:49:42 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-07-22 11:49:42 +0200 |
commit | 3d1b941137f9d8379e6e67d5abd57be5ae6ebe1a (patch) | |
tree | 43fa3d8dddba1f2bc160020e02f4b73f3521ca13 | |
parent | 3751044dc81a4b37de14b20dfc4cc7902fc36344 (diff) | |
download | libmicrohttpd-3d1b941137f9d8379e6e67d5abd57be5ae6ebe1a.tar.gz libmicrohttpd-3d1b941137f9d8379e6e67d5abd57be5ae6ebe1a.zip |
introducte MHD_RO_FREE_FUNCTION as proposed by Nicolas Mora on the list
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | doc/libmicrohttpd.texi | 8 | ||||
-rw-r--r-- | src/include/microhttpd.h | 39 | ||||
-rw-r--r-- | src/microhttpd/response.c | 10 |
4 files changed, 49 insertions, 13 deletions
@@ -1,3 +1,6 @@ | |||
1 | Mon 22 Jul 2019 11:49:03 AM CEST | ||
2 | Introduce MHD_RO_FREE_FUNCTION. -NM/CG | ||
3 | |||
1 | Tue Jul 16 19:56:14 CEST 2019 | 4 | Tue Jul 16 19:56:14 CEST 2019 |
2 | Add MHD_OPTION_HTTPS_CERT_CALLBACK2 to allow OCSP stapling | 5 | Add MHD_OPTION_HTTPS_CERT_CALLBACK2 to allow OCSP stapling |
3 | and MHD_FEATURE_HTTPS_CERT_CALLBACK2 to check for. -TR | 6 | and MHD_FEATURE_HTTPS_CERT_CALLBACK2 to check for. -TR |
@@ -102,7 +105,7 @@ Sun Apr 21 16:40:00 MSK 2019 | |||
102 | 105 | ||
103 | Fri Apr 19 23:00:00 MSK 2019 | 106 | Fri Apr 19 23:00:00 MSK 2019 |
104 | Rewritten SHA-256 calculations from scratch to avoid changing LGPL version; | 107 | Rewritten SHA-256 calculations from scratch to avoid changing LGPL version; |
105 | Added usage of GCC/Clang built-ins for bytes swap to significantly improve | 108 | Added usage of GCC/Clang built-ins for bytes swap to significantly improve |
106 | speed of MD5 and SHA-256 calculation on platforms with known endianness. | 109 | speed of MD5 and SHA-256 calculation on platforms with known endianness. |
107 | Added test for SHA-256 calculations. -EG | 110 | Added test for SHA-256 calculations. -EG |
108 | 111 | ||
diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi index 6f34d799..aa3f0242 100644 --- a/doc/libmicrohttpd.texi +++ b/doc/libmicrohttpd.texi | |||
@@ -1219,6 +1219,14 @@ Response-specific options. Passed in the varargs portion of | |||
1219 | @item MHD_RO_END | 1219 | @item MHD_RO_END |
1220 | No more options / last option. This is used to terminate the VARARGs | 1220 | No more options / last option. This is used to terminate the VARARGs |
1221 | list. | 1221 | list. |
1222 | |||
1223 | @item MHD_RO_FREE_FUNCTION | ||
1224 | Use a custom function for freeing the memory passed when using | ||
1225 | @code{MHD_create_response_from_buffer} with | ||
1226 | @code{MHD_RESPMEM_MUST_FREE}. This replaces the use of libc's | ||
1227 | @code{free()} function to release the memory with an implementation | ||
1228 | provided by the application. The next argument must be of type | ||
1229 | @code{MHD_FreeFunction}. | ||
1222 | @end table | 1230 | @end table |
1223 | @end deftp | 1231 | @end deftp |
1224 | 1232 | ||
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index 9d28cdb1..34f82154 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -132,7 +132,7 @@ typedef intptr_t ssize_t; | |||
132 | * Current version of the library. | 132 | * Current version of the library. |
133 | * 0x01093001 = 1.9.30-1. | 133 | * 0x01093001 = 1.9.30-1. |
134 | */ | 134 | */ |
135 | #define MHD_VERSION 0x00096502 | 135 | #define MHD_VERSION 0x00096503 |
136 | 136 | ||
137 | /** | 137 | /** |
138 | * MHD-internal return code for "YES". | 138 | * MHD-internal return code for "YES". |
@@ -2678,7 +2678,7 @@ _MHD_EXTERN int | |||
2678 | MHD_set_connection_value (struct MHD_Connection *connection, | 2678 | MHD_set_connection_value (struct MHD_Connection *connection, |
2679 | enum MHD_ValueKind kind, | 2679 | enum MHD_ValueKind kind, |
2680 | const char *key, | 2680 | const char *key, |
2681 | const char *value); | 2681 | const char *value); |
2682 | 2682 | ||
2683 | 2683 | ||
2684 | /** | 2684 | /** |
@@ -2708,11 +2708,11 @@ MHD_set_connection_value (struct MHD_Connection *connection, | |||
2708 | */ | 2708 | */ |
2709 | int | 2709 | int |
2710 | MHD_set_connection_value_n (struct MHD_Connection *connection, | 2710 | MHD_set_connection_value_n (struct MHD_Connection *connection, |
2711 | enum MHD_ValueKind kind, | 2711 | enum MHD_ValueKind kind, |
2712 | const char *key, | 2712 | const char *key, |
2713 | size_t key_size, | 2713 | size_t key_size, |
2714 | const char *value, | 2714 | const char *value, |
2715 | size_t value_size); | 2715 | size_t value_size); |
2716 | 2716 | ||
2717 | 2717 | ||
2718 | /** | 2718 | /** |
@@ -2806,7 +2806,7 @@ MHD_lookup_connection_value_n (struct MHD_Connection *connection, | |||
2806 | _MHD_EXTERN int | 2806 | _MHD_EXTERN int |
2807 | MHD_queue_response (struct MHD_Connection *connection, | 2807 | MHD_queue_response (struct MHD_Connection *connection, |
2808 | unsigned int status_code, | 2808 | unsigned int status_code, |
2809 | struct MHD_Response *response); | 2809 | struct MHD_Response *response); |
2810 | 2810 | ||
2811 | 2811 | ||
2812 | /** | 2812 | /** |
@@ -2895,14 +2895,31 @@ enum MHD_ResponseFlags | |||
2895 | */ | 2895 | */ |
2896 | enum MHD_ResponseOptions | 2896 | enum MHD_ResponseOptions |
2897 | { | 2897 | { |
2898 | /** | 2898 | |
2899 | * End of the list of options. | 2899 | /** |
2900 | */ | 2900 | * End of the list of options. |
2901 | MHD_RO_END = 0 | 2901 | */ |
2902 | MHD_RO_END = 0, | ||
2903 | |||
2904 | /** | ||
2905 | * Set a specific free() function | ||
2906 | * to free response buffer instead of libc void free(void * ptr) | ||
2907 | */ | ||
2908 | MHD_RO_FREE_FUNCTION = 1 | ||
2909 | |||
2902 | }; | 2910 | }; |
2903 | 2911 | ||
2904 | 2912 | ||
2905 | /** | 2913 | /** |
2914 | * This typedef is defined to be able to pass a function pointer | ||
2915 | * as a va_arg in #MHD_set_response_options() in combination | ||
2916 | * with #MHD_RO_FREE_FUNCTION. | ||
2917 | */ | ||
2918 | typedef void | ||
2919 | (*MHD_FreeFunction)(void *); | ||
2920 | |||
2921 | |||
2922 | /** | ||
2906 | * Set special flags and options for a response. | 2923 | * Set special flags and options for a response. |
2907 | * | 2924 | * |
2908 | * @param response the response to modify | 2925 | * @param response the response to modify |
diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c index 035e3054..21be419b 100644 --- a/src/microhttpd/response.c +++ b/src/microhttpd/response.c | |||
@@ -400,7 +400,6 @@ MHD_create_response_from_callback (uint64_t size, | |||
400 | return response; | 400 | return response; |
401 | } | 401 | } |
402 | 402 | ||
403 | |||
404 | /** | 403 | /** |
405 | * Set special flags and options for a response. | 404 | * Set special flags and options for a response. |
406 | * | 405 | * |
@@ -425,6 +424,15 @@ MHD_set_response_options (struct MHD_Response *response, | |||
425 | { | 424 | { |
426 | switch (ro) | 425 | switch (ro) |
427 | { | 426 | { |
427 | case MHD_RO_FREE_FUNCTION: | ||
428 | va_start (ap, flags); | ||
429 | if (NULL != (response->crfc = va_arg (ap, MHD_free_ptr))) { | ||
430 | ret = MHD_YES; | ||
431 | } else { | ||
432 | ret = MHD_NO; | ||
433 | } | ||
434 | va_end (ap); | ||
435 | break; | ||
428 | default: | 436 | default: |
429 | ret = MHD_NO; | 437 | ret = MHD_NO; |
430 | break; | 438 | break; |