libmicrohttpd

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

commit f5fc702a4d2ddf67eb1eb7dd29a0924a2aab2096
parent 5c7a9ff9c3617755bf0959b1e01c8786b7f15c0e
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu, 19 Aug 2021 14:32:15 +0300

RFC compliance: HTTP/1.1 replies for HTTP/1.0 clients

Diffstat:
Msrc/include/microhttpd.h | 2+-
Msrc/microhttpd/connection.c | 21+++++++++++++--------
2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -131,7 +131,7 @@ typedef intptr_t ssize_t; * they are parsed as decimal numbers. * Example: 0x01093001 = 1.9.30-1. */ -#define MHD_VERSION 0x00097306 +#define MHD_VERSION 0x00097307 #ifdef __has_attribute diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -1868,20 +1868,25 @@ build_header_response (struct MHD_Connection *connection) /* The HTTP version */ if (0 == (c->responseCode & MHD_ICY_FLAG)) - { - if ((0 != (r->flags & MHD_RF_HTTP_VERSION_1_0_RESPONSE)) || - (MHD_HTTP_VER_1_0 == c->http_ver) ) - { - /* TODO: use HTTP/1.1 responses for HTTP/1.0 clients. + { /* HTTP reply */ + if (0 != (r->flags & MHD_RF_HTTP_VERSION_1_0_RESPONSE)) + { /* HTTP/1.1 reply */ + /* Use HTTP/1.1 responses for HTTP/1.0 clients. * See https://datatracker.ietf.org/doc/html/rfc7230#section-2.6 */ if (! buffer_append_s (buf, &pos, buf_size, MHD_HTTP_VERSION_1_0)) return MHD_NO; } - else if (! buffer_append_s (buf, &pos, buf_size, MHD_HTTP_VERSION_1_1)) + else + { /* HTTP/1.0 reply */ + if (! buffer_append_s (buf, &pos, buf_size, MHD_HTTP_VERSION_1_1)) + return MHD_NO; + } + } + else + { /* ICY reply */ + if (! buffer_append_s (buf, &pos, buf_size, "ICY")) return MHD_NO; } - else if (! buffer_append_s (buf, &pos, buf_size, "ICY")) - return MHD_NO; /* The response code */ if (buf_size < pos + 5) /* space + code + space */