libmicrohttpd

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

commit dc54cd092af52cf3e3de0005b26f3405515d19b9
parent 2a6eada873b10f20c9a7366d19bad98b9bd945df
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 25 Oct 2015 22:07:42 +0000

realize suggestion from FC on MHD list to improve MHD_get_connection_values() when used with a bitmask

Diffstat:
MChangeLog | 4++++
Mdoc/libmicrohttpd.texi | 6++++--
Msrc/include/microhttpd.h | 7++++---
Msrc/microhttpd/connection.c | 13++++++++-----
4 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Sun Oct 25 23:05:32 CET 2015 + Return correct header kind in MHD_get_connection_values() + even if a bitmask is used for the "kind" argument. -FC/CG + Sun Oct 25 15:29:23 CET 2015 Fixing transient resource leak affecting long-lived connections with many keep-alives and HTTP request diff --git a/doc/libmicrohttpd.texi b/doc/libmicrohttpd.texi @@ -1578,7 +1578,9 @@ right now). @deftypefun int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, MHD_KeyValueIterator iterator, void *iterator_cls) -Get all the headers matching @var{kind} from the request. +Get all the headers matching @var{kind} from the request. The @var{kind} +argument can be a bitmask, ORing the various header kinds that are +requested. The @var{iterator} callback is invoked once for each header, with @var{iterator_cls} as first argument. After version 0.9.19, the @@ -1604,7 +1606,7 @@ would contain the string ``key''. @end deftypefun -@deftypefun int MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char * key, const char * value) +@deftypefun int MHD_set_connection_value (struct MHD_Connection *connection, enum MHD_ValueKind kind, const char *key, const char *value) This function can be used to append an entry to the list of HTTP headers of a connection (so that the @code{MHD_get_connection_values function} will return diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -130,7 +130,7 @@ typedef intptr_t ssize_t; * Current version of the library. * 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00094402 +#define MHD_VERSION 0x00094403 /** * MHD-internal return code for "YES". @@ -1777,7 +1777,7 @@ MHD_run_from_select (struct MHD_Daemon *daemon, * Get all of the headers from the request. * * @param connection connection to get values from - * @param kind types of values to iterate over + * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator @@ -1787,7 +1787,8 @@ MHD_run_from_select (struct MHD_Daemon *daemon, _MHD_EXTERN int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, - MHD_KeyValueIterator iterator, void *iterator_cls); + MHD_KeyValueIterator iterator, + void *iterator_cls); /** diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -116,7 +116,7 @@ * Get all of the headers from the request. * * @param connection connection to get values from - * @param kind types of values to iterate over + * @param kind types of values to iterate over, can be a bitmask * @param iterator callback to call on each header; * maybe NULL (then just count headers) * @param iterator_cls extra argument to @a iterator @@ -126,7 +126,8 @@ int MHD_get_connection_values (struct MHD_Connection *connection, enum MHD_ValueKind kind, - MHD_KeyValueIterator iterator, void *iterator_cls) + MHD_KeyValueIterator iterator, + void *iterator_cls) { int ret; struct MHD_HTTP_Header *pos; @@ -138,9 +139,11 @@ MHD_get_connection_values (struct MHD_Connection *connection, if (0 != (pos->kind & kind)) { ret++; - if ((NULL != iterator) && - (MHD_YES != iterator (iterator_cls, - kind, pos->header, pos->value))) + if ( (NULL != iterator) && + (MHD_YES != iterator (iterator_cls, + pos->kind, + pos->header, + pos->value)) ) return ret; } return ret;