libmicrohttpd

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

commit 7054ad4d559d630034eb511201131a3567110cbb
parent bc251e7f51bca12a376f39b587b828e6537c3cfc
Author: ng0 <ng0@n0.is>
Date:   Mon, 22 Jul 2019 10:52:17 +0000

Merge remote-tracking branch 'origin/master' into dev/ng0/gsoc2019

Diffstat:
MChangeLog | 14++++++++++++--
Mconfigure.ac | 6+++---
Mdoc/libmicrohttpd.texi | 27++++++++++++++++++++++++---
Mpo/libmicrohttpd.pot | 308++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/include/microhttpd.h | 61++++++++++++++++++++++++++++++++++++++++++++-----------------
Msrc/microhttpd/daemon.c | 44+++++++++++++++++++++++++++++++++++++++++++-
Msrc/microhttpd/internal.h | 8++++++++
Msrc/microhttpd/response.c | 10+++++++++-
8 files changed, 297 insertions(+), 181 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,5 +1,15 @@ +Mon 22 Jul 2019 11:49:03 AM CEST + Introduce MHD_RO_FREE_FUNCTION. -NM/CG + +Tue Jul 16 19:56:14 CEST 2019 + Add MHD_OPTION_HTTPS_CERT_CALLBACK2 to allow OCSP stapling + and MHD_FEATURE_HTTPS_CERT_CALLBACK2 to check for. -TR + +Fri Jul 05 2019 22:30:40 MSK + Releasing libmicrohttpd 0.9.65. -EG + Sun Jun 23 2019 21:27:43 MSK - Many fixes and improvments for connection-specific memory pool: + Many fixes and improvements for connection-specific memory pool: * Added asserts; * Added testing of reallocation; * Reallocation code rewritten to avoid extra allocation, when @@ -95,7 +105,7 @@ Sun Apr 21 16:40:00 MSK 2019 Fri Apr 19 23:00:00 MSK 2019 Rewritten SHA-256 calculations from scratch to avoid changing LGPL version; - Added usage of GCC/Clang built-ins for bytes swap to significantly improve + Added usage of GCC/Clang built-ins for bytes swap to significantly improve speed of MD5 and SHA-256 calculation on platforms with known endianness. Added test for SHA-256 calculations. -EG diff --git a/configure.ac b/configure.ac @@ -22,15 +22,15 @@ # AC_PREREQ([2.64]) LT_PREREQ([2.4.0]) -AC_INIT([GNU Libmicrohttpd],[0.9.64],[libmicrohttpd@gnu.org]) +AC_INIT([GNU Libmicrohttpd],[0.9.65],[libmicrohttpd@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) AM_INIT_AUTOMAKE([silent-rules] [subdir-objects]) AC_CONFIG_HEADERS([MHD_config.h]) AC_CONFIG_MACRO_DIR([m4]) -LIB_VERSION_CURRENT=63 +LIB_VERSION_CURRENT=64 LIB_VERSION_REVISION=0 -LIB_VERSION_AGE=51 +LIB_VERSION_AGE=52 AC_SUBST(LIB_VERSION_CURRENT) AC_SUBST(LIB_VERSION_REVISION) AC_SUBST(LIB_VERSION_AGE) diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi @@ -622,7 +622,7 @@ Only useful in combination with @code{MHD_USE_TLS}. This option will only work if the underyling TLS library supports it (i.e. GnuTLS after 3.6.3). If the TLS library does not support it, MHD may ignore the option and proceed -without supporting this features. +without supporting this features. @item MHD_USE_INSECURE_TLS_EARLY_DATA Tell the TLS library to support TLS v1.3 early data (0-RTT) with the @@ -633,7 +633,7 @@ GET requests! You have been warned. This option will only work if the underyling TLS library supports it (i.e. GnuTLS after 3.6.3). If the TLS library does not support it, MHD may ignore the option and proceed -without supporting this features. +without supporting this features. @end table @end deftp @@ -892,6 +892,19 @@ information provided. The callback is expected to access the SNI data using gnutls_server_name_get(). Using this option requires GnuTLS 3.0 or higher. +@item MHD_OPTION_HTTPS_CERT_CALLBACK2 +@cindex SSL +@cindex TLS +@cindex SNI +@cindex OCSP +Use a callback to determine which X.509 certificate should be +used for a given HTTPS connection. This option should be +followed by a argument of type `gnutls_certificate_retrieve_function3 *`. +This option provides an +alternative/extension to #MHD_OPTION_HTTPS_CERT_CALLBACK. +You must use this version if you want to use OCSP stapling. +Using this option requires GnuTLS 3.6.3 or higher. + @item MHD_OPTION_GNUTLS_PSK_CRED_HANDLER @cindex SSL @cindex TLS @@ -1206,6 +1219,14 @@ Response-specific options. Passed in the varargs portion of @item MHD_RO_END No more options / last option. This is used to terminate the VARARGs list. + +@item MHD_RO_FREE_FUNCTION +Use a custom function for freeing the memory passed when using +@code{MHD_create_response_from_buffer} with +@code{MHD_RESPMEM_MUST_FREE}. This replaces the use of libc's +@code{free()} function to release the memory with an implementation +provided by the application. The next argument must be of type +@code{MHD_ContentReaderFreeCallback}. @end table @end deftp @@ -2956,7 +2977,7 @@ connections have been handled. @section Obtaining state information about a connection -@deftypefun {const union MHD_ConnectionInfo *} MHD_get_connection_info (struct MHD_Connection *daemon, enum MHD_ConnectionInfoType infoType, ...) +@deftypefun {const union MHD_ConnectionInfo *} MHD_get_connection_info (struct MHD_Connection *connection, enum MHD_ConnectionInfoType infoType, ...) Obtain information about the given connection. @table @var diff --git a/po/libmicrohttpd.pot b/po/libmicrohttpd.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: GNU libmicrohttpd 0.9.64\n" +"Project-Id-Version: GNU libmicrohttpd 0.9.65\n" "Report-Msgid-Bugs-To: libmicrohttpd@gnu.org\n" -"POT-Creation-Date: 2019-06-09 20:25+0300\n" +"POT-Creation-Date: 2019-07-05 22:27+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -92,525 +92,525 @@ msgstr "" msgid "Fatal error in GNU libmicrohttpd %s:%u: %s\n" msgstr "" -#: src/microhttpd/daemon.c:434 +#: src/microhttpd/daemon.c:449 msgid "Failed to add IP connection count node\n" msgstr "" -#: src/microhttpd/daemon.c:492 +#: src/microhttpd/daemon.c:507 msgid "Failed to find previously-added IP address\n" msgstr "" -#: src/microhttpd/daemon.c:498 +#: src/microhttpd/daemon.c:513 msgid "Previously-added IP address had counter of zero\n" msgstr "" -#: src/microhttpd/daemon.c:599 +#: src/microhttpd/daemon.c:614 msgid "" "Failed to setup x509 certificate/key: pre 3.X.X version of GnuTLS does not " "support setting key password" msgstr "" -#: src/microhttpd/daemon.c:653 +#: src/microhttpd/daemon.c:668 #, c-format msgid "Error: invalid credentials type %d specified.\n" msgstr "" -#: src/microhttpd/daemon.c:1052 +#: src/microhttpd/daemon.c:1067 #, c-format msgid "Maximum socket in select set: %d\n" msgstr "" -#: src/microhttpd/daemon.c:1113 +#: src/microhttpd/daemon.c:1128 msgid "" "MHD_get_fdset2() called with except_fd_set set to NULL. Such behavior is " "unsupported.\n" msgstr "" -#: src/microhttpd/daemon.c:1319 src/microhttpd/daemon.c:6558 +#: src/microhttpd/daemon.c:1334 src/microhttpd/daemon.c:6573 msgid "" "Initiated daemon shutdown while \"upgraded\" connection was not closed.\n" msgstr "" -#: src/microhttpd/daemon.c:1333 src/microhttpd/daemon.c:1568 +#: src/microhttpd/daemon.c:1348 src/microhttpd/daemon.c:1583 msgid "Failed to forward to application " msgstr "" -#: src/microhttpd/daemon.c:1500 src/microhttpd/daemon.c:1622 +#: src/microhttpd/daemon.c:1515 src/microhttpd/daemon.c:1637 msgid "Failed to forward to remote client " msgstr "" -#: src/microhttpd/daemon.c:1687 +#: src/microhttpd/daemon.c:1702 msgid "Error preparing select\n" msgstr "" -#: src/microhttpd/daemon.c:1721 src/microhttpd/daemon.c:1873 -#: src/microhttpd/daemon.c:2017 +#: src/microhttpd/daemon.c:1736 src/microhttpd/daemon.c:1888 +#: src/microhttpd/daemon.c:2032 #, c-format msgid "Error during select (%d): `%s'\n" msgstr "" -#: src/microhttpd/daemon.c:1770 src/microhttpd/daemon.c:1894 -#: src/microhttpd/daemon.c:2086 +#: src/microhttpd/daemon.c:1785 src/microhttpd/daemon.c:1909 +#: src/microhttpd/daemon.c:2101 #, c-format msgid "Error during poll: `%s'\n" msgstr "" -#: src/microhttpd/daemon.c:1857 src/microhttpd/daemon.c:1999 +#: src/microhttpd/daemon.c:1872 src/microhttpd/daemon.c:2014 msgid "Failed to add FD to fd_set\n" msgstr "" -#: src/microhttpd/daemon.c:2138 +#: src/microhttpd/daemon.c:2153 msgid "Processing thread terminating. Closing connection\n" msgstr "" -#: src/microhttpd/daemon.c:2167 +#: src/microhttpd/daemon.c:2182 msgid "" "Failed to signal thread termination via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:2238 +#: src/microhttpd/daemon.c:2253 msgid "Internal server error. This should be impossible.\n" msgstr "" -#: src/microhttpd/daemon.c:2248 src/microhttpd/daemon.c:2285 +#: src/microhttpd/daemon.c:2263 src/microhttpd/daemon.c:2300 msgid "PSK not supported by this server.\n" msgstr "" -#: src/microhttpd/daemon.c:2262 +#: src/microhttpd/daemon.c:2277 msgid "PSK authentication failed: gnutls_malloc failed to allocate memory\n" msgstr "" -#: src/microhttpd/daemon.c:2271 +#: src/microhttpd/daemon.c:2286 msgid "PSK authentication failed: PSK too long\n" msgstr "" -#: src/microhttpd/daemon.c:2367 src/microhttpd/daemon.c:6202 +#: src/microhttpd/daemon.c:2382 src/microhttpd/daemon.c:6217 #, c-format msgid "Socket descriptor larger than FD_SETSIZE: %d > %d\n" msgstr "" -#: src/microhttpd/daemon.c:2383 +#: src/microhttpd/daemon.c:2398 #, c-format msgid "Failed to set SO_NOSIGPIPE on accepted socket: %s\n" msgstr "" -#: src/microhttpd/daemon.c:2400 src/microhttpd/daemon.c:3223 +#: src/microhttpd/daemon.c:2415 src/microhttpd/daemon.c:3238 #, c-format msgid "Accepted connection on socket %d\n" msgstr "" -#: src/microhttpd/daemon.c:2412 src/microhttpd/daemon.c:2602 +#: src/microhttpd/daemon.c:2427 src/microhttpd/daemon.c:2617 msgid "Server reached connection limit. Closing inbound connection.\n" msgstr "" -#: src/microhttpd/daemon.c:2430 +#: src/microhttpd/daemon.c:2445 msgid "Connection rejected by application. Closing connection.\n" msgstr "" -#: src/microhttpd/daemon.c:2463 src/microhttpd/daemon.c:2483 -#: src/microhttpd/daemon.c:3809 +#: src/microhttpd/daemon.c:2478 src/microhttpd/daemon.c:2498 +#: src/microhttpd/daemon.c:3824 #, c-format msgid "Error allocating memory: %s\n" msgstr "" -#: src/microhttpd/daemon.c:2555 +#: src/microhttpd/daemon.c:2570 #, c-format msgid "Failed to setup TLS credentials: unknown credential type %d\n" msgstr "" -#: src/microhttpd/daemon.c:2564 +#: src/microhttpd/daemon.c:2579 msgid "Unknown credential type" msgstr "" -#: src/microhttpd/daemon.c:2666 src/microhttpd/daemon.c:4299 -#: src/microhttpd/daemon.c:4332 src/microhttpd/daemon.c:5494 -#: src/microhttpd/daemon.c:5511 src/microhttpd/connection.c:4099 +#: src/microhttpd/daemon.c:2681 src/microhttpd/daemon.c:4314 +#: src/microhttpd/daemon.c:4347 src/microhttpd/daemon.c:5509 +#: src/microhttpd/daemon.c:5526 src/microhttpd/connection.c:4130 #: src/microhttpd/response.c:1003 src/microhttpd/response.c:1029 #, c-format msgid "Call to epoll_ctl failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:2691 +#: src/microhttpd/daemon.c:2706 msgid "Failed to signal new connection via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:2796 src/microhttpd/daemon.c:3307 -#: src/microhttpd/daemon.c:6448 src/microhttpd/connection.c:1190 +#: src/microhttpd/daemon.c:2811 src/microhttpd/daemon.c:3322 +#: src/microhttpd/daemon.c:6463 src/microhttpd/connection.c:1190 #: src/microhttpd/connection.c:1209 msgid "Failed to remove FD from epoll set\n" msgstr "" -#: src/microhttpd/daemon.c:2845 +#: src/microhttpd/daemon.c:2860 msgid "Cannot suspend connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n" msgstr "" -#: src/microhttpd/daemon.c:2851 +#: src/microhttpd/daemon.c:2866 msgid "Error: connection scheduled for \"upgrade\" cannot be suspended" msgstr "" -#: src/microhttpd/daemon.c:2874 +#: src/microhttpd/daemon.c:2889 msgid "Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n" msgstr "" -#: src/microhttpd/daemon.c:2888 +#: src/microhttpd/daemon.c:2903 msgid "Failed to signal resume via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:3020 +#: src/microhttpd/daemon.c:3035 msgid "" "Failed to signal resume of connection via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:3066 +#: src/microhttpd/daemon.c:3081 #, c-format msgid "Failed to set nonblocking mode on new client socket: %s\n" msgstr "" -#: src/microhttpd/daemon.c:3079 +#: src/microhttpd/daemon.c:3094 msgid "Failed to set noninheritable mode on new client socket.\n" msgstr "" -#: src/microhttpd/daemon.c:3088 +#: src/microhttpd/daemon.c:3103 msgid "Failed to reset buffering mode on new client socket.\n" msgstr "" -#: src/microhttpd/daemon.c:3161 +#: src/microhttpd/daemon.c:3176 #, c-format msgid "Error accepting connection: %s\n" msgstr "" -#: src/microhttpd/daemon.c:3178 +#: src/microhttpd/daemon.c:3193 msgid "" "Hit process or system resource limit at FIRST connection. This is really bad " "as there is no sane way to proceed. Will try busy waiting for system " "resources to become magically available.\n" msgstr "" -#: src/microhttpd/daemon.c:3192 +#: src/microhttpd/daemon.c:3207 #, c-format msgid "" "Hit process or system resource limit at %u connections, temporarily " "suspending accept(). Consider setting a lower MHD_OPTION_CONNECTION_LIMIT.\n" msgstr "" -#: src/microhttpd/daemon.c:3204 +#: src/microhttpd/daemon.c:3219 #, c-format msgid "Failed to set nonblocking mode on incoming connection socket: %s\n" msgstr "" -#: src/microhttpd/daemon.c:3216 +#: src/microhttpd/daemon.c:3231 msgid "Failed to set noninheritable mode on incoming connection socket.\n" msgstr "" -#: src/microhttpd/daemon.c:3264 src/microhttpd/daemon.c:6600 -#: src/microhttpd/daemon.c:6632 src/microhttpd/daemon.c:6732 +#: src/microhttpd/daemon.c:3279 src/microhttpd/daemon.c:6615 +#: src/microhttpd/daemon.c:6647 src/microhttpd/daemon.c:6747 msgid "Failed to join a thread\n" msgstr "" -#: src/microhttpd/daemon.c:3368 +#: src/microhttpd/daemon.c:3383 msgid "Illegal call to MHD_get_timeout\n" msgstr "" -#: src/microhttpd/daemon.c:3565 +#: src/microhttpd/daemon.c:3580 msgid "" "MHD_run_from_select() called with except_fd_set set to NULL. Such behavior " "is deprecated.\n" msgstr "" -#: src/microhttpd/daemon.c:3645 +#: src/microhttpd/daemon.c:3660 msgid "Could not obtain daemon fdsets" msgstr "" -#: src/microhttpd/daemon.c:3662 +#: src/microhttpd/daemon.c:3677 msgid "Could not add listen socket to fdset" msgstr "" -#: src/microhttpd/daemon.c:3690 +#: src/microhttpd/daemon.c:3705 msgid "Could not add control inter-thread communication channel FD to fdset" msgstr "" -#: src/microhttpd/daemon.c:3746 +#: src/microhttpd/daemon.c:3761 #, c-format msgid "select failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:3891 src/microhttpd/daemon.c:4038 +#: src/microhttpd/daemon.c:3906 src/microhttpd/daemon.c:4053 #, c-format msgid "poll failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:4168 src/microhttpd/daemon.c:4399 +#: src/microhttpd/daemon.c:4183 src/microhttpd/daemon.c:4414 #, c-format msgid "Call to epoll_wait failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:4351 src/microhttpd/daemon.c:4808 +#: src/microhttpd/daemon.c:4366 src/microhttpd/daemon.c:4823 msgid "Failed to remove listen FD from epoll set\n" msgstr "" -#: src/microhttpd/daemon.c:4816 +#: src/microhttpd/daemon.c:4831 msgid "Failed to signal quiesce via inter-thread communication channel" msgstr "" -#: src/microhttpd/daemon.c:4838 +#: src/microhttpd/daemon.c:4853 msgid "failed to signal quiesce via inter-thread communication channel" msgstr "" -#: src/microhttpd/daemon.c:4949 +#: src/microhttpd/daemon.c:4964 msgid "Warning: Too large timeout value, ignored.\n" msgstr "" -#: src/microhttpd/daemon.c:4988 +#: src/microhttpd/daemon.c:5003 msgid "" "Warning: Zero size, specified for thread pool size, is ignored. Thread pool " "is not used.\n" msgstr "" -#: src/microhttpd/daemon.c:4996 +#: src/microhttpd/daemon.c:5011 msgid "" "Warning: \"1\", specified for thread pool size, is ignored. Thread pool is " "not used.\n" msgstr "" -#: src/microhttpd/daemon.c:5008 +#: src/microhttpd/daemon.c:5023 #, c-format msgid "Specified thread pool size (%u) too big\n" msgstr "" -#: src/microhttpd/daemon.c:5019 +#: src/microhttpd/daemon.c:5034 msgid "" "MHD_OPTION_THREAD_POOL_SIZE option is specified but " "MHD_USE_INTERNAL_POLLING_THREAD flag is not specified.\n" msgstr "" -#: src/microhttpd/daemon.c:5028 +#: src/microhttpd/daemon.c:5043 msgid "" "Both MHD_OPTION_THREAD_POOL_SIZE option and MHD_USE_THREAD_PER_CONNECTION " "flag are specified.\n" msgstr "" -#: src/microhttpd/daemon.c:5045 src/microhttpd/daemon.c:5057 -#: src/microhttpd/daemon.c:5069 src/microhttpd/daemon.c:5081 -#: src/microhttpd/daemon.c:5132 src/microhttpd/daemon.c:5160 -#: src/microhttpd/daemon.c:5179 +#: src/microhttpd/daemon.c:5060 src/microhttpd/daemon.c:5072 +#: src/microhttpd/daemon.c:5084 src/microhttpd/daemon.c:5096 +#: src/microhttpd/daemon.c:5147 src/microhttpd/daemon.c:5175 +#: src/microhttpd/daemon.c:5194 #, c-format msgid "MHD HTTPS option %d passed to MHD but MHD_USE_TLS not set\n" msgstr "" -#: src/microhttpd/daemon.c:5101 +#: src/microhttpd/daemon.c:5116 msgid "Error initializing DH parameters\n" msgstr "" -#: src/microhttpd/daemon.c:5111 +#: src/microhttpd/daemon.c:5126 msgid "Diffie-Hellman parameters string too long\n" msgstr "" -#: src/microhttpd/daemon.c:5122 +#: src/microhttpd/daemon.c:5137 msgid "Bad Diffie-Hellman parameters format\n" msgstr "" -#: src/microhttpd/daemon.c:5149 +#: src/microhttpd/daemon.c:5164 #, c-format msgid "Setting priorities to `%s' failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5168 +#: src/microhttpd/daemon.c:5183 msgid "" "MHD_OPTION_HTTPS_CERT_CALLBACK requires building MHD with GnuTLS >= 3.0\n" msgstr "" -#: src/microhttpd/daemon.c:5202 +#: src/microhttpd/daemon.c:5217 msgid "" "MHD_OPTION_LISTEN_SOCKET specified for daemon with MHD_USE_NO_LISTEN_SOCKET " "flag set.\n" msgstr "" -#: src/microhttpd/daemon.c:5238 +#: src/microhttpd/daemon.c:5253 msgid "TCP fastopen is not supported on this platform\n" msgstr "" -#: src/microhttpd/daemon.c:5257 +#: src/microhttpd/daemon.c:5272 msgid "" "Flag MHD_USE_PEDANTIC_CHECKS is ignored because another behavior is " "specified by MHD_OPTION_STRICT_CLIENT.\n" msgstr "" -#: src/microhttpd/daemon.c:5389 +#: src/microhttpd/daemon.c:5404 #, c-format msgid "MHD HTTPS option %d passed to MHD compiled without GNUtls >= 3\n" msgstr "" -#: src/microhttpd/daemon.c:5402 +#: src/microhttpd/daemon.c:5417 #, c-format msgid "MHD HTTPS option %d passed to MHD compiled without HTTPS support\n" msgstr "" -#: src/microhttpd/daemon.c:5408 +#: src/microhttpd/daemon.c:5423 #, c-format msgid "Invalid option %d! (Did you terminate the list with MHD_OPTION_END?)\n" msgstr "" -#: src/microhttpd/daemon.c:5438 +#: src/microhttpd/daemon.c:5453 #, c-format msgid "Call to epoll_create1 failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5448 +#: src/microhttpd/daemon.c:5463 msgid "Failed to set noninheritable mode on epoll FD.\n" msgstr "" -#: src/microhttpd/daemon.c:5691 +#: src/microhttpd/daemon.c:5706 msgid "" "Warning: MHD_USE_THREAD_PER_CONNECTION must be used only with " "MHD_USE_INTERNAL_POLLING_THREAD. Flag MHD_USE_INTERNAL_POLLING_THREAD was " "added. Consider setting MHD_USE_INTERNAL_POLLING_THREAD explicitly.\n" msgstr "" -#: src/microhttpd/daemon.c:5739 +#: src/microhttpd/daemon.c:5754 msgid "Using debug build of libmicrohttpd.\n" msgstr "" -#: src/microhttpd/daemon.c:5753 +#: src/microhttpd/daemon.c:5768 #, c-format msgid "Failed to create inter-thread communication channel: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5769 +#: src/microhttpd/daemon.c:5784 msgid "" "file descriptor for inter-thread communication channel exceeds maximum " "value\n" msgstr "" -#: src/microhttpd/daemon.c:5789 +#: src/microhttpd/daemon.c:5804 msgid "Specified value for NC_SIZE too large\n" msgstr "" -#: src/microhttpd/daemon.c:5803 +#: src/microhttpd/daemon.c:5818 #, c-format msgid "Failed to allocate memory for nonce-nc map: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5820 +#: src/microhttpd/daemon.c:5835 msgid "MHD failed to initialize nonce-nc mutex\n" msgstr "" -#: src/microhttpd/daemon.c:5840 +#: src/microhttpd/daemon.c:5855 msgid "MHD thread pooling only works with MHD_USE_INTERNAL_POLLING_THREAD\n" msgstr "" -#: src/microhttpd/daemon.c:5864 +#: src/microhttpd/daemon.c:5879 #, c-format msgid "Failed to create socket for listening: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5885 src/microhttpd/daemon.c:5904 -#: src/microhttpd/daemon.c:5927 src/microhttpd/daemon.c:5964 -#: src/microhttpd/daemon.c:6041 src/microhttpd/daemon.c:6072 +#: src/microhttpd/daemon.c:5900 src/microhttpd/daemon.c:5919 +#: src/microhttpd/daemon.c:5942 src/microhttpd/daemon.c:5979 +#: src/microhttpd/daemon.c:6056 src/microhttpd/daemon.c:6087 #, c-format msgid "setsockopt failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5937 +#: src/microhttpd/daemon.c:5952 msgid "Cannot allow listening address reuse: SO_REUSEPORT not defined\n" msgstr "" -#: src/microhttpd/daemon.c:5972 +#: src/microhttpd/daemon.c:5987 msgid "" "Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined\n" msgstr "" -#: src/microhttpd/daemon.c:6052 +#: src/microhttpd/daemon.c:6067 #, c-format msgid "Failed to bind to port %u: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6083 +#: src/microhttpd/daemon.c:6098 #, c-format msgid "Failed to listen for connections: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6114 +#: src/microhttpd/daemon.c:6129 #, c-format msgid "Failed to get listen port number: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6124 +#: src/microhttpd/daemon.c:6139 msgid "" "Failed to get listen port number (`struct sockaddr_storage` too small!?)\n" msgstr "" -#: src/microhttpd/daemon.c:6165 +#: src/microhttpd/daemon.c:6180 msgid "Unknown address family!\n" msgstr "" -#: src/microhttpd/daemon.c:6179 +#: src/microhttpd/daemon.c:6194 #, c-format msgid "Failed to set nonblocking mode on listening socket: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6221 +#: src/microhttpd/daemon.c:6236 msgid "" "Combining MHD_USE_THREAD_PER_CONNECTION and MHD_USE_EPOLL is not supported.\n" msgstr "" -#: src/microhttpd/daemon.c:6235 src/microhttpd/daemon.c:6248 +#: src/microhttpd/daemon.c:6250 src/microhttpd/daemon.c:6263 msgid "MHD failed to initialize IP connection limit mutex\n" msgstr "" -#: src/microhttpd/daemon.c:6267 +#: src/microhttpd/daemon.c:6282 msgid "Failed to initialize TLS support\n" msgstr "" -#: src/microhttpd/daemon.c:6294 +#: src/microhttpd/daemon.c:6309 #, c-format msgid "Failed to create listen thread: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6342 +#: src/microhttpd/daemon.c:6357 #, c-format msgid "Failed to create worker inter-thread communication channel: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6353 +#: src/microhttpd/daemon.c:6368 msgid "" "File descriptor for worker inter-thread communication channel exceeds " "maximum value\n" msgstr "" -#: src/microhttpd/daemon.c:6378 +#: src/microhttpd/daemon.c:6393 msgid "MHD failed to initialize cleanup connection mutex\n" msgstr "" -#: src/microhttpd/daemon.c:6392 +#: src/microhttpd/daemon.c:6407 #, c-format msgid "Failed to create pool thread: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6545 src/microhttpd/daemon.c:6576 +#: src/microhttpd/daemon.c:6560 src/microhttpd/daemon.c:6591 msgid "MHD_stop_daemon() called while we have suspended connections.\n" msgstr "" -#: src/microhttpd/daemon.c:6585 src/microhttpd/daemon.c:6714 +#: src/microhttpd/daemon.c:6600 src/microhttpd/daemon.c:6729 msgid "Failed to signal shutdown via inter-thread communication channel" msgstr "" -#: src/microhttpd/daemon.c:6677 +#: src/microhttpd/daemon.c:6692 msgid "Failed to signal shutdown via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:7144 +#: src/microhttpd/daemon.c:7159 msgid "Failed to initialize winsock\n" msgstr "" -#: src/microhttpd/daemon.c:7147 +#: src/microhttpd/daemon.c:7162 msgid "Winsock version 2.2 is not available\n" msgstr "" -#: src/microhttpd/daemon.c:7155 src/microhttpd/daemon.c:7159 +#: src/microhttpd/daemon.c:7170 src/microhttpd/daemon.c:7174 msgid "Failed to initialise multithreading in libgcrypt\n" msgstr "" -#: src/microhttpd/daemon.c:7164 +#: src/microhttpd/daemon.c:7179 msgid "libgcrypt is too old. MHD was compiled for libgcrypt 1.6.0 or newer\n" msgstr "" @@ -622,134 +622,134 @@ msgstr "" msgid "Closing connection (application reported error generating data)\n" msgstr "" -#: src/microhttpd/connection.c:1368 +#: src/microhttpd/connection.c:1364 msgid "Closing connection (out of memory)\n" msgstr "" -#: src/microhttpd/connection.c:1415 +#: src/microhttpd/connection.c:1411 msgid "Closing connection (application error generating response)\n" msgstr "" -#: src/microhttpd/connection.c:2000 +#: src/microhttpd/connection.c:2029 #, c-format msgid "" "Error processing request (HTTP response code is %u (`%s')). Closing " "connection.\n" msgstr "" -#: src/microhttpd/connection.c:2026 src/microhttpd/connection.c:3038 +#: src/microhttpd/connection.c:2055 src/microhttpd/connection.c:3068 msgid "Closing connection (failed to queue response)\n" msgstr "" -#: src/microhttpd/connection.c:2036 src/microhttpd/connection.c:3811 -#: src/microhttpd/connection.c:3934 +#: src/microhttpd/connection.c:2065 src/microhttpd/connection.c:3842 +#: src/microhttpd/connection.c:3965 msgid "Closing connection (failed to create response header)\n" msgstr "" -#: src/microhttpd/connection.c:2082 src/microhttpd/connection.c:3192 -#: src/microhttpd/connection.c:3260 src/microhttpd/connection.c:3576 +#: src/microhttpd/connection.c:2111 src/microhttpd/connection.c:3223 +#: src/microhttpd/connection.c:3291 src/microhttpd/connection.c:3607 #, c-format msgid "In function %s handling connection at state: %s\n" msgstr "" -#: src/microhttpd/connection.c:2300 +#: src/microhttpd/connection.c:2329 msgid "Not enough memory in pool to allocate header record!\n" msgstr "" -#: src/microhttpd/connection.c:2346 +#: src/microhttpd/connection.c:2375 msgid "Not enough memory in pool to parse cookies!\n" msgstr "" -#: src/microhttpd/connection.c:2576 src/microhttpd/connection.c:2761 +#: src/microhttpd/connection.c:2605 src/microhttpd/connection.c:2790 msgid "Application reported internal error, closing connection.\n" msgstr "" -#: src/microhttpd/connection.c:2629 src/microhttpd/connection.c:2706 +#: src/microhttpd/connection.c:2658 src/microhttpd/connection.c:2735 msgid "" "Received malformed HTTP request (bad chunked encoding). Closing connection.\n" msgstr "" -#: src/microhttpd/connection.c:2769 +#: src/microhttpd/connection.c:2798 msgid "libmicrohttpd API violation" msgstr "" -#: src/microhttpd/connection.c:2784 +#: src/microhttpd/connection.c:2813 msgid "" "WARNING: incomplete upload processing and connection not suspended may " "result in hung connection.\n" msgstr "" -#: src/microhttpd/connection.c:2854 +#: src/microhttpd/connection.c:2884 msgid "Received malformed line (no colon). Closing connection.\n" msgstr "" -#: src/microhttpd/connection.c:3016 +#: src/microhttpd/connection.c:3046 msgid "Received HTTP 1.1 request without `Host' header.\n" msgstr "" -#: src/microhttpd/connection.c:3027 +#: src/microhttpd/connection.c:3057 msgid "Closing connection (failed to create response)\n" msgstr "" -#: src/microhttpd/connection.c:3171 +#: src/microhttpd/connection.c:3202 msgid "Socket disconnected while reading request.\n" msgstr "" -#: src/microhttpd/connection.c:3177 +#: src/microhttpd/connection.c:3208 msgid "Connection socket is closed due to error when reading request.\n" msgstr "" -#: src/microhttpd/connection.c:3286 +#: src/microhttpd/connection.c:3317 #, c-format msgid "Failed to send data in request for %s.\n" msgstr "" -#: src/microhttpd/connection.c:3295 +#: src/microhttpd/connection.c:3326 #, c-format msgid "Sent 100 continue response: `%.*s'\n" msgstr "" -#: src/microhttpd/connection.c:3319 +#: src/microhttpd/connection.c:3350 msgid "Connection was closed while sending response headers.\n" msgstr "" -#: src/microhttpd/connection.c:3360 +#: src/microhttpd/connection.c:3391 msgid "Data offset exceeds limit" msgstr "" -#: src/microhttpd/connection.c:3369 +#: src/microhttpd/connection.c:3400 #, c-format msgid "Sent %d-byte DATA response: `%.*s'\n" msgstr "" -#: src/microhttpd/connection.c:3386 +#: src/microhttpd/connection.c:3417 #, c-format msgid "Failed to send data in request for `%s'.\n" msgstr "" -#: src/microhttpd/connection.c:3414 src/microhttpd/connection.c:3442 +#: src/microhttpd/connection.c:3445 src/microhttpd/connection.c:3473 msgid "Connection was closed while sending response body.\n" msgstr "" -#: src/microhttpd/connection.c:3465 +#: src/microhttpd/connection.c:3496 msgid "Internal error\n" msgstr "" -#: src/microhttpd/connection.c:3538 +#: src/microhttpd/connection.c:3569 msgid "" "Failed to signal end of connection via inter-thread communication channel" msgstr "" -#: src/microhttpd/connection.c:4285 +#: src/microhttpd/connection.c:4316 msgid "Attempted to queue response on wrong thread!\n" msgstr "" -#: src/microhttpd/connection.c:4296 +#: src/microhttpd/connection.c:4327 msgid "" "Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n" msgstr "" -#: src/microhttpd/connection.c:4305 +#: src/microhttpd/connection.c:4336 msgid "Application used invalid status code for 'upgrade' response!\n" msgstr "" diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -132,7 +132,7 @@ typedef intptr_t ssize_t; * Current version of the library. * 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00096401 +#define MHD_VERSION 0x00096503 /** * MHD-internal return code for "YES". @@ -1646,7 +1646,18 @@ enum MHD_OPTION * gnutls_psk_set_server_credentials_function. It is used to * retrieve the shared key for a given username. */ - MHD_OPTION_GNUTLS_PSK_CRED_HANDLER = 30 + MHD_OPTION_GNUTLS_PSK_CRED_HANDLER = 30, + + /** + * Use a callback to determine which X.509 certificate should be + * used for a given HTTPS connection. This option should be + * followed by a argument of type `gnutls_certificate_retrieve_function3 *`. + * This option provides an + * alternative/extension to #MHD_OPTION_HTTPS_CERT_CALLBACK. + * You must use this version if you want to use OCSP stapling. + * Using this option requires GnuTLS 3.6.3 or higher. + */ + MHD_OPTION_HTTPS_CERT_CALLBACK2 = 31 }; @@ -2245,10 +2256,12 @@ typedef ssize_t /** - * This method is called by libmicrohttpd if we - * are done with a content reader. It should - * be used to free resources associated with the - * content reader. + * This method is called by libmicrohttpd if we are done with a content + * reader. It should be used to free resources associated with the content + * reader. + * + * It is also used as a va_arg in #MHD_set_response_options() in combination + * with #MHD_RO_FREE_FUNCTION. * * @param cls closure * @ingroup response @@ -2667,7 +2680,7 @@ _MHD_EXTERN int MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, - const char *value); + const char *value); /** @@ -2697,11 +2710,11 @@ MHD_set_connection_value (struct MHD_Connection *connection, */ int MHD_set_connection_value_n (struct MHD_Connection *connection, - enum MHD_ValueKind kind, - const char *key, + enum MHD_ValueKind kind, + const char *key, size_t key_size, - const char *value, - size_t value_size); + const char *value, + size_t value_size); /** @@ -2795,7 +2808,7 @@ MHD_lookup_connection_value_n (struct MHD_Connection *connection, _MHD_EXTERN int MHD_queue_response (struct MHD_Connection *connection, unsigned int status_code, - struct MHD_Response *response); + struct MHD_Response *response); /** @@ -2884,10 +2897,18 @@ enum MHD_ResponseFlags */ enum MHD_ResponseOptions { - /** - * End of the list of options. - */ - MHD_RO_END = 0 + + /** + * End of the list of options. + */ + MHD_RO_END = 0, + + /** + * Set a specific free() function + * to free response buffer instead of libc void free(void * ptr) + */ + MHD_RO_FREE_FUNCTION = 1 + }; @@ -3927,7 +3948,13 @@ enum MHD_FEATURE /** * Get whether MHD supports threads. */ - MHD_FEATURE_THREADS + MHD_FEATURE_THREADS = 22, + + /** + * Get whether option #MHD_OPTION_HTTPS_CERT_CALLBACK2 is + * supported. + */ + MHD_FEATURE_HTTPS_CERT_CALLBACK2 = 23 }; diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -546,6 +546,14 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) daemon->cert_callback); } #endif +#if GNUTLS_VERSION_NUMBER >= 0x030603 + else if (NULL != daemon->cert_callback2) + { + gnutls_certificate_set_retrieve_function3 (daemon->x509_cred, + daemon->cert_callback2); + } +#endif + if (NULL != daemon->https_mem_trust) { size_t paramlen; @@ -634,6 +642,10 @@ MHD_init_daemon_certificate (struct MHD_Daemon *daemon) if (NULL != daemon->cert_callback) return 0; #endif +#if GNUTLS_VERSION_NUMBER >= 0x030603 + else if (NULL != daemon->cert_callback2) + return 0; +#endif #ifdef HAVE_MESSAGES MHD_DLOG (daemon, "You need to specify a certificate and key location\n"); @@ -2540,7 +2552,7 @@ internal_add_connection (struct MHD_Daemon *daemon, #if (GNUTLS_VERSION_NUMBER+0 >= 0x030605) if (0 != (daemon->options & MHD_USE_INSECURE_TLS_EARLY_DATA)) flags |= GNUTLS_ENABLE_EARLY_DATA; -#endif +#endif connection->tls_state = MHD_TLS_CONN_INIT; MHD_set_https_callbacks (connection); gnutls_init (&connection->tls_session, @@ -4930,6 +4942,9 @@ parse_options_va (struct MHD_Daemon *daemon, #if GNUTLS_VERSION_MAJOR >= 3 gnutls_certificate_retrieve_function2 *pgcrf; #endif +#if GNUTLS_VERSION_NUMBER >= 0x030603 + gnutls_certificate_retrieve_function3 *pgcrf2; +#endif #endif /* HTTPS_SUPPORT */ while (MHD_OPTION_END != (opt = (enum MHD_OPTION) va_arg (ap, int))) @@ -5196,6 +5211,26 @@ parse_options_va (struct MHD_Daemon *daemon, #endif break; #endif + case MHD_OPTION_HTTPS_CERT_CALLBACK2: +#if GNUTLS_VERSION_NUMBER < 0x030603 +#ifdef HAVE_MESSAGES + MHD_DLOG (daemon, + _("MHD_OPTION_HTTPS_CERT_CALLBACK2 requires building MHD with GnuTLS >= 3.6.3\n")); +#endif + return MHD_NO; +#else + pgcrf2 = va_arg (ap, + gnutls_certificate_retrieve_function3 *); + if (0 != (daemon->options & MHD_USE_TLS)) + daemon->cert_callback2 = pgcrf2; + else +#ifdef HAVE_MESSAGES + MHD_DLOG (daemon, + _("MHD HTTPS option %d passed to MHD but MHD_USE_TLS not set\n"), + opt); +#endif + break; +#endif #endif /* HTTPS_SUPPORT */ #ifdef DAUTH_SUPPORT case MHD_OPTION_DIGEST_AUTH_RANDOM: @@ -5347,6 +5382,7 @@ parse_options_va (struct MHD_Daemon *daemon, case MHD_OPTION_HTTPS_PRIORITIES: case MHD_OPTION_ARRAY: case MHD_OPTION_HTTPS_CERT_CALLBACK: + case MHD_OPTION_HTTPS_CERT_CALLBACK2: if (MHD_YES != parse_options (daemon, servaddr, opt, @@ -6960,6 +6996,12 @@ MHD_is_feature_supported(enum MHD_FEATURE feature) #else /* !HTTPS_SUPPORT || GNUTLS_VERSION_MAJOR < 3 */ return MHD_NO; #endif /* !HTTPS_SUPPORT || GNUTLS_VERSION_MAJOR < 3 */ + case MHD_FEATURE_HTTPS_CERT_CALLBACK2: +#if defined(HTTPS_SUPPORT) && GNUTLS_VERSION_NUMBER >= 0x030603 + return MHD_YES; +#else /* !HTTPS_SUPPORT || GNUTLS_VERSION_NUMBER < 0x030603 */ + return MHD_NO; +#endif /* !HTTPS_SUPPORT || GNUTLS_VERSION_NUMBER < 0x030603 */ case MHD_FEATURE_IPv6: #ifdef HAVE_INET6 return MHD_YES; diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -1670,6 +1670,14 @@ struct MHD_Daemon void *cred_callback_cls; #endif +#if GNUTLS_VERSION_NUMBER >= 0x030603 + /** + * Function that can be used to obtain the certificate. Needed + * for OCSP stapling support. See #MHD_OPTION_HTTPS_CERT_CALLBACK2. + */ + gnutls_certificate_retrieve_function3 *cert_callback2; +#endif + /** * Pointer to our SSL/TLS key (in ASCII) in memory. */ diff --git a/src/microhttpd/response.c b/src/microhttpd/response.c @@ -400,7 +400,6 @@ MHD_create_response_from_callback (uint64_t size, return response; } - /** * Set special flags and options for a response. * @@ -425,6 +424,15 @@ MHD_set_response_options (struct MHD_Response *response, { switch (ro) { + case MHD_RO_FREE_FUNCTION: + va_start (ap, flags); + if (NULL != (response->crfc = va_arg (ap, MHD_ContentReaderFreeCallback))) { + ret = MHD_YES; + } else { + ret = MHD_NO; + } + va_end (ap); + break; default: ret = MHD_NO; break;