libmicrohttpd

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

commit f5d59eb3a7c54cd13550ed906a67f1bff630b2c6
parent 878c8c7e019b95aaace6a4a9edf1e584abc5ceae
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 24 Dec 2019 15:33:05 +0100

Given post body "a&b=1", how should MHD interpret the data?

I'm at the end of a long investigation and it's come down to that question
for post_process_urlencoded() in MHD.

MHD currently calls back with ("a&b", "1").  The app I'm working breaks
when it doesn't receive a callback for "b".  The http client in this case
(that did the urlencoding) is google-http-java-client 1.23.0.

The client behavior may be questionable, but MHD's behavior doesn't seem
right either.  Isn't there some principle, "clients should strive for
conformance, servers should strive for forgiveness".

I've attached a patch to MHD to add a failing test, but without a fix.

As for relevant standards, the W3C[1] is not detailed enough to cover it.
The WhatWG[2] is more specific and allows for empty values and even empty
keys.  I'd like to callout uriparser[3], another C library I've patched in
as a work-around.  Uriparser documents their handling of these cases well:

* NULL in the value member means there was no '=' in the item text as with
"?abc&def".
* An empty string in the value member means there was '=' in the item as
with "?abc=&def".

[1] https://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
[2] https://url.spec.whatwg.org/#urlencoded-parsing
[3] https://uriparser.github.io/doc/api/latest/#querystrings

commit aa0534af56d135e1b261d127af09c22015c1ff87
Author: Ethan Tuttle <ethan@ethantuttle.com>
Date:   Tue Dec 24 03:50:59 2019 -0800

    urlencoding post-processor: add failing tests for keys without values

Diffstat:
MChangeLog | 4++++
Mpo/libmicrohttpd.pot | 326++++++++++++++++++++++++++++++++++++++++----------------------------------------
Msrc/microhttpd/test_postprocessor.c | 39+++++++++++++++++++++++++++++++--------
3 files changed, 198 insertions(+), 171 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Tue 24 Dec 2019 03:32:18 PM CET + Adding patch from Ethan Tuttle with test case for urlencoding + in post-processor for keys without values. -CG/ET + Sun 15 Dec 2019 02:12:02 PM CET Fix send() call (affects Mac OS X). #5977 -CG/fbrault Releasing libmicrohttpd 0.9.69. -CG diff --git a/po/libmicrohttpd.pot b/po/libmicrohttpd.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: GNU libmicrohttpd 0.9.68\n" +"Project-Id-Version: GNU libmicrohttpd 0.9.69\n" "Report-Msgid-Bugs-To: libmicrohttpd@gnu.org\n" -"POT-Creation-Date: 2019-10-26 19:30+0200\n" +"POT-Creation-Date: 2019-12-15 14:18+0100\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" @@ -37,53 +37,53 @@ msgstr "" msgid "Failed to close FD.\n" msgstr "" -#: src/microhttpd/digestauth.c:602 +#: src/microhttpd/digestauth.c:601 msgid "" "Stale nonce received. If this happens a lot, you should probably increase " "the size of the nonce array.\n" msgstr "" -#: src/microhttpd/digestauth.c:808 +#: src/microhttpd/digestauth.c:807 msgid "Failed to allocate memory for copy of URI arguments\n" msgstr "" -#: src/microhttpd/digestauth.c:951 +#: src/microhttpd/digestauth.c:949 msgid "Authentication failed, invalid timestamp format.\n" msgstr "" -#: src/microhttpd/digestauth.c:1014 +#: src/microhttpd/digestauth.c:1009 msgid "Authentication failed, invalid format.\n" msgstr "" -#: src/microhttpd/digestauth.c:1024 +#: src/microhttpd/digestauth.c:1019 msgid "Authentication failed, invalid nc format.\n" msgstr "" -#: src/microhttpd/digestauth.c:1050 +#: src/microhttpd/digestauth.c:1044 msgid "Failed to allocate memory for auth header processing\n" msgstr "" -#: src/microhttpd/digestauth.c:1110 +#: src/microhttpd/digestauth.c:1104 msgid "Authentication failed, URI does not match.\n" msgstr "" -#: src/microhttpd/digestauth.c:1129 +#: src/microhttpd/digestauth.c:1123 msgid "Authentication failed, arguments do not match.\n" msgstr "" -#: src/microhttpd/digestauth.c:1286 +#: src/microhttpd/digestauth.c:1279 msgid "digest size missmatch" msgstr "" -#: src/microhttpd/digestauth.c:1379 +#: src/microhttpd/digestauth.c:1372 msgid "Could not register nonce (is the nonce array size zero?).\n" msgstr "" -#: src/microhttpd/digestauth.c:1404 +#: src/microhttpd/digestauth.c:1397 msgid "Failed to allocate memory for auth response header\n" msgstr "" -#: src/microhttpd/digestauth.c:1440 +#: src/microhttpd/digestauth.c:1433 msgid "Failed to add Digest auth header\n" msgstr "" @@ -92,535 +92,535 @@ msgstr "" msgid "Fatal error in GNU libmicrohttpd %s:%u: %s\n" msgstr "" -#: src/microhttpd/daemon.c:449 +#: src/microhttpd/daemon.c:451 msgid "Failed to add IP connection count node\n" msgstr "" -#: src/microhttpd/daemon.c:507 +#: src/microhttpd/daemon.c:509 msgid "Failed to find previously-added IP address\n" msgstr "" -#: src/microhttpd/daemon.c:513 +#: src/microhttpd/daemon.c:515 msgid "Previously-added IP address had counter of zero\n" msgstr "" -#: src/microhttpd/daemon.c:623 +#: src/microhttpd/daemon.c:625 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:681 +#: src/microhttpd/daemon.c:684 #, c-format msgid "Error: invalid credentials type %d specified.\n" msgstr "" -#: src/microhttpd/daemon.c:1080 +#: src/microhttpd/daemon.c:1088 #, c-format msgid "Maximum socket in select set: %d\n" msgstr "" -#: src/microhttpd/daemon.c:1141 +#: src/microhttpd/daemon.c:1149 msgid "" "MHD_get_fdset2() called with except_fd_set set to NULL. Such behavior is " "unsupported.\n" msgstr "" -#: src/microhttpd/daemon.c:1348 src/microhttpd/daemon.c:6704 +#: src/microhttpd/daemon.c:1356 src/microhttpd/daemon.c:6728 msgid "" "Initiated daemon shutdown while \"upgraded\" connection was not closed.\n" msgstr "" -#: src/microhttpd/daemon.c:1363 src/microhttpd/daemon.c:1602 +#: src/microhttpd/daemon.c:1371 src/microhttpd/daemon.c:1606 msgid "Failed to forward to application " msgstr "" -#: src/microhttpd/daemon.c:1532 src/microhttpd/daemon.c:1658 +#: src/microhttpd/daemon.c:1536 src/microhttpd/daemon.c:1662 msgid "Failed to forward to remote client " msgstr "" -#: src/microhttpd/daemon.c:1724 +#: src/microhttpd/daemon.c:1730 msgid "Error preparing select\n" msgstr "" -#: src/microhttpd/daemon.c:1758 src/microhttpd/daemon.c:1910 -#: src/microhttpd/daemon.c:2054 +#: src/microhttpd/daemon.c:1764 src/microhttpd/daemon.c:1918 +#: src/microhttpd/daemon.c:2062 #, c-format msgid "Error during select (%d): `%s'\n" msgstr "" -#: src/microhttpd/daemon.c:1807 src/microhttpd/daemon.c:1931 -#: src/microhttpd/daemon.c:2123 +#: src/microhttpd/daemon.c:1813 src/microhttpd/daemon.c:1939 +#: src/microhttpd/daemon.c:2131 #, c-format msgid "Error during poll: `%s'\n" msgstr "" -#: src/microhttpd/daemon.c:1894 src/microhttpd/daemon.c:2036 +#: src/microhttpd/daemon.c:1902 src/microhttpd/daemon.c:2044 msgid "Failed to add FD to fd_set\n" msgstr "" -#: src/microhttpd/daemon.c:2176 +#: src/microhttpd/daemon.c:2184 msgid "Processing thread terminating. Closing connection\n" msgstr "" -#: src/microhttpd/daemon.c:2206 +#: src/microhttpd/daemon.c:2214 msgid "" "Failed to signal thread termination via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:2277 +#: src/microhttpd/daemon.c:2289 msgid "Internal server error. This should be impossible.\n" msgstr "" -#: src/microhttpd/daemon.c:2287 src/microhttpd/daemon.c:2325 +#: src/microhttpd/daemon.c:2299 src/microhttpd/daemon.c:2337 msgid "PSK not supported by this server.\n" msgstr "" -#: src/microhttpd/daemon.c:2302 +#: src/microhttpd/daemon.c:2314 msgid "PSK authentication failed: gnutls_malloc failed to allocate memory\n" msgstr "" -#: src/microhttpd/daemon.c:2311 +#: src/microhttpd/daemon.c:2323 msgid "PSK authentication failed: PSK too long\n" msgstr "" -#: src/microhttpd/daemon.c:2407 src/microhttpd/daemon.c:6341 +#: src/microhttpd/daemon.c:2421 src/microhttpd/daemon.c:6365 #, c-format msgid "Socket descriptor larger than FD_SETSIZE: %d > %d\n" msgstr "" -#: src/microhttpd/daemon.c:2423 +#: src/microhttpd/daemon.c:2437 #, c-format msgid "Failed to set SO_NOSIGPIPE on accepted socket: %s\n" msgstr "" -#: src/microhttpd/daemon.c:2440 src/microhttpd/daemon.c:3299 +#: src/microhttpd/daemon.c:2454 src/microhttpd/daemon.c:3313 #, c-format msgid "Accepted connection on socket %d\n" msgstr "" -#: src/microhttpd/daemon.c:2453 src/microhttpd/daemon.c:2650 +#: src/microhttpd/daemon.c:2467 src/microhttpd/daemon.c:2664 msgid "Server reached connection limit. Closing inbound connection.\n" msgstr "" -#: src/microhttpd/daemon.c:2471 +#: src/microhttpd/daemon.c:2485 msgid "Connection rejected by application. Closing connection.\n" msgstr "" -#: src/microhttpd/daemon.c:2504 src/microhttpd/daemon.c:2524 -#: src/microhttpd/daemon.c:3886 +#: src/microhttpd/daemon.c:2518 src/microhttpd/daemon.c:2538 +#: src/microhttpd/daemon.c:3901 #, c-format msgid "Error allocating memory: %s\n" msgstr "" -#: src/microhttpd/daemon.c:2602 +#: src/microhttpd/daemon.c:2616 #, c-format msgid "Failed to setup TLS credentials: unknown credential type %d\n" msgstr "" -#: src/microhttpd/daemon.c:2611 +#: src/microhttpd/daemon.c:2625 msgid "Unknown credential type" msgstr "" -#: src/microhttpd/daemon.c:2714 src/microhttpd/daemon.c:4378 -#: src/microhttpd/daemon.c:4411 src/microhttpd/daemon.c:5622 -#: src/microhttpd/daemon.c:5639 src/microhttpd/connection.c:3796 -#: src/microhttpd/response.c:1052 src/microhttpd/response.c:1078 +#: src/microhttpd/daemon.c:2728 src/microhttpd/daemon.c:4397 +#: src/microhttpd/daemon.c:4430 src/microhttpd/daemon.c:5644 +#: src/microhttpd/daemon.c:5661 src/microhttpd/connection.c:3798 +#: src/microhttpd/response.c:1053 src/microhttpd/response.c:1079 #, c-format msgid "Call to epoll_ctl failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:2741 +#: src/microhttpd/daemon.c:2755 msgid "Failed to signal new connection via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:2846 src/microhttpd/daemon.c:3383 -#: src/microhttpd/daemon.c:6591 src/microhttpd/connection.c:802 -#: src/microhttpd/connection.c:821 +#: src/microhttpd/daemon.c:2860 src/microhttpd/daemon.c:3396 +#: src/microhttpd/daemon.c:6615 src/microhttpd/connection.c:805 +#: src/microhttpd/connection.c:824 msgid "Failed to remove FD from epoll set\n" msgstr "" -#: src/microhttpd/daemon.c:2896 +#: src/microhttpd/daemon.c:2910 msgid "Cannot suspend connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n" msgstr "" -#: src/microhttpd/daemon.c:2903 +#: src/microhttpd/daemon.c:2917 msgid "Error: connection scheduled for \"upgrade\" cannot be suspended" msgstr "" -#: src/microhttpd/daemon.c:2927 +#: src/microhttpd/daemon.c:2941 msgid "Cannot resume connections without enabling MHD_ALLOW_SUSPEND_RESUME!\n" msgstr "" -#: src/microhttpd/daemon.c:2942 +#: src/microhttpd/daemon.c:2956 msgid "Failed to signal resume via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:3077 +#: src/microhttpd/daemon.c:3091 msgid "" "Failed to signal resume of connection via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:3124 +#: src/microhttpd/daemon.c:3138 #, c-format msgid "Failed to set nonblocking mode on new client socket: %s\n" msgstr "" -#: src/microhttpd/daemon.c:3137 +#: src/microhttpd/daemon.c:3151 msgid "Failed to set noninheritable mode on new client socket.\n" msgstr "" -#: src/microhttpd/daemon.c:3146 +#: src/microhttpd/daemon.c:3160 msgid "Failed to reset buffering mode on new client socket.\n" msgstr "" -#: src/microhttpd/daemon.c:3219 +#: src/microhttpd/daemon.c:3233 #, c-format msgid "Error accepting connection: %s\n" msgstr "" -#: src/microhttpd/daemon.c:3237 +#: src/microhttpd/daemon.c:3251 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:3252 +#: src/microhttpd/daemon.c:3266 #, 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:3268 +#: src/microhttpd/daemon.c:3282 #, c-format msgid "Failed to disable TCP Nagle on socket: %s\n" msgstr "" -#: src/microhttpd/daemon.c:3279 +#: src/microhttpd/daemon.c:3293 #, c-format msgid "Failed to set nonblocking mode on incoming connection socket: %s\n" msgstr "" -#: src/microhttpd/daemon.c:3292 +#: src/microhttpd/daemon.c:3306 msgid "Failed to set noninheritable mode on incoming connection socket.\n" msgstr "" -#: src/microhttpd/daemon.c:3340 src/microhttpd/daemon.c:6748 -#: src/microhttpd/daemon.c:6780 src/microhttpd/daemon.c:6882 +#: src/microhttpd/daemon.c:3354 src/microhttpd/daemon.c:6772 +#: src/microhttpd/daemon.c:6804 src/microhttpd/daemon.c:6906 msgid "Failed to join a thread\n" msgstr "" -#: src/microhttpd/daemon.c:3444 +#: src/microhttpd/daemon.c:3457 msgid "Illegal call to MHD_get_timeout\n" msgstr "" -#: src/microhttpd/daemon.c:3641 +#: src/microhttpd/daemon.c:3654 msgid "" "MHD_run_from_select() called with except_fd_set set to NULL. Such behavior " "is deprecated.\n" msgstr "" -#: src/microhttpd/daemon.c:3721 +#: src/microhttpd/daemon.c:3734 msgid "Could not obtain daemon fdsets" msgstr "" -#: src/microhttpd/daemon.c:3738 +#: src/microhttpd/daemon.c:3751 msgid "Could not add listen socket to fdset" msgstr "" -#: src/microhttpd/daemon.c:3767 +#: src/microhttpd/daemon.c:3780 msgid "Could not add control inter-thread communication channel FD to fdset" msgstr "" -#: src/microhttpd/daemon.c:3823 +#: src/microhttpd/daemon.c:3838 #, c-format msgid "select failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:3968 src/microhttpd/daemon.c:4116 +#: src/microhttpd/daemon.c:3983 src/microhttpd/daemon.c:4131 #, c-format msgid "poll failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:4247 src/microhttpd/daemon.c:4478 +#: src/microhttpd/daemon.c:4264 src/microhttpd/daemon.c:4497 #, c-format msgid "Call to epoll_wait failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:4430 src/microhttpd/daemon.c:4888 +#: src/microhttpd/daemon.c:4449 src/microhttpd/daemon.c:4910 msgid "Failed to remove listen FD from epoll set\n" msgstr "" -#: src/microhttpd/daemon.c:4897 +#: src/microhttpd/daemon.c:4919 msgid "Failed to signal quiesce via inter-thread communication channel" msgstr "" -#: src/microhttpd/daemon.c:4920 +#: src/microhttpd/daemon.c:4942 msgid "failed to signal quiesce via inter-thread communication channel" msgstr "" -#: src/microhttpd/daemon.c:5034 +#: src/microhttpd/daemon.c:5056 msgid "Warning: Too large timeout value, ignored.\n" msgstr "" -#: src/microhttpd/daemon.c:5079 +#: src/microhttpd/daemon.c:5101 msgid "" "Warning: Zero size, specified for thread pool size, is ignored. Thread pool " "is not used.\n" msgstr "" -#: src/microhttpd/daemon.c:5088 +#: src/microhttpd/daemon.c:5110 msgid "" "Warning: \"1\", specified for thread pool size, is ignored. Thread pool is " "not used.\n" msgstr "" -#: src/microhttpd/daemon.c:5101 +#: src/microhttpd/daemon.c:5123 #, c-format msgid "Specified thread pool size (%u) too big\n" msgstr "" -#: src/microhttpd/daemon.c:5112 +#: src/microhttpd/daemon.c:5134 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:5121 +#: src/microhttpd/daemon.c:5143 msgid "" "Both MHD_OPTION_THREAD_POOL_SIZE option and MHD_USE_THREAD_PER_CONNECTION " "flag are specified.\n" msgstr "" -#: src/microhttpd/daemon.c:5139 src/microhttpd/daemon.c:5152 -#: src/microhttpd/daemon.c:5165 src/microhttpd/daemon.c:5178 -#: src/microhttpd/daemon.c:5230 src/microhttpd/daemon.c:5259 -#: src/microhttpd/daemon.c:5280 src/microhttpd/daemon.c:5302 +#: src/microhttpd/daemon.c:5161 src/microhttpd/daemon.c:5174 +#: src/microhttpd/daemon.c:5187 src/microhttpd/daemon.c:5200 +#: src/microhttpd/daemon.c:5252 src/microhttpd/daemon.c:5281 +#: src/microhttpd/daemon.c:5302 src/microhttpd/daemon.c:5324 #, c-format msgid "MHD HTTPS option %d passed to MHD but MHD_USE_TLS not set\n" msgstr "" -#: src/microhttpd/daemon.c:5198 +#: src/microhttpd/daemon.c:5220 msgid "Error initializing DH parameters\n" msgstr "" -#: src/microhttpd/daemon.c:5208 +#: src/microhttpd/daemon.c:5230 msgid "Diffie-Hellman parameters string too long\n" msgstr "" -#: src/microhttpd/daemon.c:5219 +#: src/microhttpd/daemon.c:5241 msgid "Bad Diffie-Hellman parameters format\n" msgstr "" -#: src/microhttpd/daemon.c:5247 +#: src/microhttpd/daemon.c:5269 #, c-format msgid "Setting priorities to `%s' failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5268 +#: src/microhttpd/daemon.c:5290 msgid "" "MHD_OPTION_HTTPS_CERT_CALLBACK requires building MHD with GnuTLS >= 3.0\n" msgstr "" -#: src/microhttpd/daemon.c:5290 +#: src/microhttpd/daemon.c:5312 msgid "" "MHD_OPTION_HTTPS_CERT_CALLBACK2 requires building MHD with GnuTLS >= 3.6.3\n" msgstr "" -#: src/microhttpd/daemon.c:5325 +#: src/microhttpd/daemon.c:5347 msgid "" "MHD_OPTION_LISTEN_SOCKET specified for daemon with MHD_USE_NO_LISTEN_SOCKET " "flag set.\n" msgstr "" -#: src/microhttpd/daemon.c:5361 +#: src/microhttpd/daemon.c:5383 msgid "TCP fastopen is not supported on this platform\n" msgstr "" -#: src/microhttpd/daemon.c:5380 +#: src/microhttpd/daemon.c:5402 msgid "" "Flag MHD_USE_PEDANTIC_CHECKS is ignored because another behavior is " "specified by MHD_OPTION_STRICT_CLIENT.\n" msgstr "" -#: src/microhttpd/daemon.c:5515 +#: src/microhttpd/daemon.c:5537 #, c-format msgid "MHD HTTPS option %d passed to MHD compiled without GNUtls >= 3\n" msgstr "" -#: src/microhttpd/daemon.c:5529 +#: src/microhttpd/daemon.c:5551 #, c-format msgid "MHD HTTPS option %d passed to MHD compiled without HTTPS support\n" msgstr "" -#: src/microhttpd/daemon.c:5536 +#: src/microhttpd/daemon.c:5558 #, c-format msgid "Invalid option %d! (Did you terminate the list with MHD_OPTION_END?)\n" msgstr "" -#: src/microhttpd/daemon.c:5566 +#: src/microhttpd/daemon.c:5588 #, c-format msgid "Call to epoll_create1 failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5576 +#: src/microhttpd/daemon.c:5598 msgid "Failed to set noninheritable mode on epoll FD.\n" msgstr "" -#: src/microhttpd/daemon.c:5826 +#: src/microhttpd/daemon.c:5850 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:5874 +#: src/microhttpd/daemon.c:5898 msgid "Using debug build of libmicrohttpd.\n" msgstr "" -#: src/microhttpd/daemon.c:5888 +#: src/microhttpd/daemon.c:5912 #, c-format msgid "Failed to create inter-thread communication channel: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5905 +#: src/microhttpd/daemon.c:5929 msgid "" "file descriptor for inter-thread communication channel exceeds maximum " "value\n" msgstr "" -#: src/microhttpd/daemon.c:5925 +#: src/microhttpd/daemon.c:5949 msgid "Specified value for NC_SIZE too large\n" msgstr "" -#: src/microhttpd/daemon.c:5939 +#: src/microhttpd/daemon.c:5963 #, c-format msgid "Failed to allocate memory for nonce-nc map: %s\n" msgstr "" -#: src/microhttpd/daemon.c:5956 +#: src/microhttpd/daemon.c:5980 msgid "MHD failed to initialize nonce-nc mutex\n" msgstr "" -#: src/microhttpd/daemon.c:5977 +#: src/microhttpd/daemon.c:6001 msgid "MHD thread pooling only works with MHD_USE_INTERNAL_POLLING_THREAD\n" msgstr "" -#: src/microhttpd/daemon.c:6001 +#: src/microhttpd/daemon.c:6025 #, c-format msgid "Failed to create socket for listening: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6022 src/microhttpd/daemon.c:6041 -#: src/microhttpd/daemon.c:6064 src/microhttpd/daemon.c:6102 -#: src/microhttpd/daemon.c:6180 src/microhttpd/daemon.c:6211 +#: src/microhttpd/daemon.c:6046 src/microhttpd/daemon.c:6065 +#: src/microhttpd/daemon.c:6088 src/microhttpd/daemon.c:6126 +#: src/microhttpd/daemon.c:6204 src/microhttpd/daemon.c:6235 #, c-format msgid "setsockopt failed: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6075 +#: src/microhttpd/daemon.c:6099 msgid "Cannot allow listening address reuse: SO_REUSEPORT not defined\n" msgstr "" -#: src/microhttpd/daemon.c:6111 +#: src/microhttpd/daemon.c:6135 msgid "" "Cannot disallow listening address reuse: SO_EXCLUSIVEADDRUSE not defined\n" msgstr "" -#: src/microhttpd/daemon.c:6191 +#: src/microhttpd/daemon.c:6215 #, c-format msgid "Failed to bind to port %u: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6222 +#: src/microhttpd/daemon.c:6246 #, c-format msgid "Failed to listen for connections: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6253 +#: src/microhttpd/daemon.c:6277 #, c-format msgid "Failed to get listen port number: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6264 +#: src/microhttpd/daemon.c:6288 msgid "" "Failed to get listen port number (`struct sockaddr_storage` too small!?)\n" msgstr "" -#: src/microhttpd/daemon.c:6305 +#: src/microhttpd/daemon.c:6329 msgid "Unknown address family!\n" msgstr "" -#: src/microhttpd/daemon.c:6318 +#: src/microhttpd/daemon.c:6342 #, c-format msgid "Failed to set nonblocking mode on listening socket: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6361 +#: src/microhttpd/daemon.c:6385 msgid "" "Combining MHD_USE_THREAD_PER_CONNECTION and MHD_USE_EPOLL is not supported.\n" msgstr "" -#: src/microhttpd/daemon.c:6375 src/microhttpd/daemon.c:6388 +#: src/microhttpd/daemon.c:6399 src/microhttpd/daemon.c:6412 msgid "MHD failed to initialize IP connection limit mutex\n" msgstr "" -#: src/microhttpd/daemon.c:6407 +#: src/microhttpd/daemon.c:6431 msgid "Failed to initialize TLS support\n" msgstr "" -#: src/microhttpd/daemon.c:6435 +#: src/microhttpd/daemon.c:6459 #, c-format msgid "Failed to create listen thread: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6484 +#: src/microhttpd/daemon.c:6508 #, c-format msgid "Failed to create worker inter-thread communication channel: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6496 +#: src/microhttpd/daemon.c:6520 msgid "" "File descriptor for worker inter-thread communication channel exceeds " "maximum value\n" msgstr "" -#: src/microhttpd/daemon.c:6521 +#: src/microhttpd/daemon.c:6545 msgid "MHD failed to initialize cleanup connection mutex\n" msgstr "" -#: src/microhttpd/daemon.c:6535 +#: src/microhttpd/daemon.c:6559 #, c-format msgid "Failed to create pool thread: %s\n" msgstr "" -#: src/microhttpd/daemon.c:6690 src/microhttpd/daemon.c:6723 +#: src/microhttpd/daemon.c:6714 src/microhttpd/daemon.c:6747 msgid "MHD_stop_daemon() called while we have suspended connections.\n" msgstr "" -#: src/microhttpd/daemon.c:6733 src/microhttpd/daemon.c:6864 +#: src/microhttpd/daemon.c:6757 src/microhttpd/daemon.c:6888 msgid "Failed to signal shutdown via inter-thread communication channel" msgstr "" -#: src/microhttpd/daemon.c:6826 +#: src/microhttpd/daemon.c:6850 msgid "Failed to signal shutdown via inter-thread communication channel." msgstr "" -#: src/microhttpd/daemon.c:7302 +#: src/microhttpd/daemon.c:7326 msgid "Failed to initialize winsock\n" msgstr "" -#: src/microhttpd/daemon.c:7305 +#: src/microhttpd/daemon.c:7329 msgid "Winsock version 2.2 is not available\n" msgstr "" -#: src/microhttpd/daemon.c:7313 src/microhttpd/daemon.c:7317 +#: src/microhttpd/daemon.c:7337 src/microhttpd/daemon.c:7341 msgid "Failed to initialise multithreading in libgcrypt\n" msgstr "" -#: src/microhttpd/daemon.c:7323 +#: src/microhttpd/daemon.c:7347 msgid "libgcrypt is too old. MHD was compiled for libgcrypt 1.6.0 or newer\n" msgstr "" @@ -628,68 +628,68 @@ msgstr "" msgid "Close socket failed.\n" msgstr "" -#: src/microhttpd/connection.c:928 +#: src/microhttpd/connection.c:932 msgid "Closing connection (application reported error generating data)\n" msgstr "" -#: src/microhttpd/connection.c:977 +#: src/microhttpd/connection.c:981 msgid "Closing connection (out of memory)\n" msgstr "" -#: src/microhttpd/connection.c:1025 +#: src/microhttpd/connection.c:1029 msgid "Closing connection (application error generating response)\n" msgstr "" -#: src/microhttpd/connection.c:1654 +#: src/microhttpd/connection.c:1657 #, c-format msgid "" "Error processing request (HTTP response code is %u (`%s')). Closing " "connection.\n" msgstr "" -#: src/microhttpd/connection.c:1681 src/microhttpd/connection.c:2719 +#: src/microhttpd/connection.c:1684 src/microhttpd/connection.c:2719 msgid "Closing connection (failed to queue response)\n" msgstr "" -#: src/microhttpd/connection.c:1692 src/microhttpd/connection.c:3527 -#: src/microhttpd/connection.c:3636 +#: src/microhttpd/connection.c:1695 src/microhttpd/connection.c:3529 +#: src/microhttpd/connection.c:3638 msgid "Closing connection (failed to create response header)\n" msgstr "" -#: src/microhttpd/connection.c:1738 src/microhttpd/connection.c:2879 +#: src/microhttpd/connection.c:1741 src/microhttpd/connection.c:2879 #: src/microhttpd/connection.c:2947 src/microhttpd/connection.c:3300 #, c-format msgid "In function %s handling connection at state: %s\n" msgstr "" -#: src/microhttpd/connection.c:1956 +#: src/microhttpd/connection.c:1958 msgid "Not enough memory in pool to allocate header record!\n" msgstr "" -#: src/microhttpd/connection.c:2003 +#: src/microhttpd/connection.c:2005 msgid "Not enough memory in pool to parse cookies!\n" msgstr "" -#: src/microhttpd/connection.c:2234 src/microhttpd/connection.c:2436 +#: src/microhttpd/connection.c:2236 src/microhttpd/connection.c:2438 msgid "Application reported internal error, closing connection.\n" msgstr "" -#: src/microhttpd/connection.c:2301 src/microhttpd/connection.c:2380 +#: src/microhttpd/connection.c:2303 src/microhttpd/connection.c:2382 msgid "" "Received malformed HTTP request (bad chunked encoding). Closing connection.\n" msgstr "" -#: src/microhttpd/connection.c:2444 +#: src/microhttpd/connection.c:2446 msgid "libmicrohttpd API violation" msgstr "" -#: src/microhttpd/connection.c:2460 +#: src/microhttpd/connection.c:2462 msgid "" "WARNING: incomplete upload processing and connection not suspended may " "result in hung connection.\n" msgstr "" -#: src/microhttpd/connection.c:2532 +#: src/microhttpd/connection.c:2534 msgid "Received malformed line (no colon). Closing connection.\n" msgstr "" @@ -750,43 +750,43 @@ msgid "" "Failed to signal end of connection via inter-thread communication channel" msgstr "" -#: src/microhttpd/connection.c:3985 +#: src/microhttpd/connection.c:3989 msgid "Attempted to queue response on wrong thread!\n" msgstr "" -#: src/microhttpd/connection.c:3997 +#: src/microhttpd/connection.c:4001 msgid "" "Attempted 'upgrade' connection on daemon without MHD_ALLOW_UPGRADE option!\n" msgstr "" -#: src/microhttpd/connection.c:4007 +#: src/microhttpd/connection.c:4011 msgid "Application used invalid status code for 'upgrade' response!\n" msgstr "" -#: src/microhttpd/response.c:914 +#: src/microhttpd/response.c:915 msgid "" "Invalid response for upgrade: application failed to set the 'Upgrade' " "header!\n" msgstr "" -#: src/microhttpd/response.c:955 +#: src/microhttpd/response.c:956 msgid "Failed to make loopback sockets non-blocking.\n" msgstr "" -#: src/microhttpd/response.c:974 +#: src/microhttpd/response.c:975 msgid "Failed to set SO_NOSIGPIPE on loopback sockets.\n" msgstr "" -#: src/microhttpd/response.c:994 +#: src/microhttpd/response.c:995 #, c-format msgid "Socketpair descriptor larger than FD_SETSIZE: %d > %d\n" msgstr "" -#: src/microhttpd/response.c:1075 +#: src/microhttpd/response.c:1076 msgid "Error cleaning up while handling epoll error" msgstr "" -#: src/microhttpd/mhd_itc.h:354 +#: src/microhttpd/mhd_itc.h:355 msgid "Failed to destroy ITC.\n" msgstr "" diff --git a/src/microhttpd/test_postprocessor.c b/src/microhttpd/test_postprocessor.c @@ -17,13 +17,11 @@ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - /** * @file test_postprocessor.c * @brief Testcase for postprocessor * @author Christian Grothoff */ - #include "platform.h" #include "microhttpd.h" #include "internal.h" @@ -42,8 +40,18 @@ * five NULL-entries. */ const char *want[] = { +#define URL_NOVALUE1_DATA "abc&x=5" +#define URL_NOVALUE1_START 0 + "abc", NULL, NULL, NULL, NULL, + "x", NULL, NULL, NULL, "5", +#define URL_NOVALUE1_END (URL_NOVALUE1_START + 10) +#define URL_NOVALUE2_DATA "abc=&x=5" +#define URL_NOVALUE2_START URL_NOVALUE1_END + "abc", NULL, NULL, NULL, "", + "x", NULL, NULL, NULL, "5", +#define URL_NOVALUE2_END (URL_NOVALUE2_START + 10) #define URL_DATA "abc=def&x=5" -#define URL_START 0 +#define URL_START URL_NOVALUE2_END "abc", NULL, NULL, NULL, "def", "x", NULL, NULL, NULL, "5", #define URL_END (URL_START + 10) @@ -125,12 +133,14 @@ value_checker (void *cls, static int -test_urlencoding (void) +test_urlencoding_case (unsigned int want_start, + unsigned int want_end, + const char *url_data) { struct MHD_Connection connection; struct MHD_HTTP_Header header; struct MHD_PostProcessor *pp; - unsigned int want_off = URL_START; + unsigned int want_off = want_start; size_t i; size_t delta; size_t size; @@ -147,21 +157,34 @@ test_urlencoding (void) pp = MHD_create_post_processor (&connection, 1024, &value_checker, &want_off); i = 0; - size = strlen (URL_DATA); + size = strlen (url_data); while (i < size) { delta = 1 + MHD_random_ () % (size - i); - MHD_post_process (pp, &URL_DATA[i], delta); + MHD_post_process (pp, &url_data[i], delta); i += delta; } MHD_destroy_post_processor (pp); - if (want_off != URL_END) + if (want_off != want_end) return 1; return 0; } static int +test_urlencoding (void) +{ + unsigned int errorCount = 0; + errorCount += test_urlencoding_case (URL_START, URL_END, URL_DATA); + errorCount += test_urlencoding_case (URL_NOVALUE1_START, URL_NOVALUE1_END, + URL_NOVALUE1_DATA); + errorCount += test_urlencoding_case (URL_NOVALUE2_START, URL_NOVALUE2_END, + URL_NOVALUE2_DATA); + return errorCount; +} + + +static int test_multipart_garbage (void) { struct MHD_Connection connection;