diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-08-19 20:11:13 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-08-19 20:11:13 +0300 |
commit | 6f48db46b16579198fd48862fb8ec4829216ba2d (patch) | |
tree | 8482fda64d977ad1e1ceee82727c70dc6bf9d67a | |
parent | dab2db20fdee8f0604ba23fe7a28c047bf36c2c1 (diff) | |
download | libmicrohttpd-6f48db46b16579198fd48862fb8ec4829216ba2d.tar.gz libmicrohttpd-6f48db46b16579198fd48862fb8ec4829216ba2d.zip |
Added response flag to always send "Connection:" header
-rw-r--r-- | src/include/microhttpd.h | 20 | ||||
-rw-r--r-- | src/microhttpd/connection.c | 6 |
2 files changed, 18 insertions, 8 deletions
diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h index a5731e23..d2eaeff3 100644 --- a/src/include/microhttpd.h +++ b/src/include/microhttpd.h | |||
@@ -96,7 +96,7 @@ extern "C" | |||
96 | * they are parsed as decimal numbers. | 96 | * they are parsed as decimal numbers. |
97 | * Example: 0x01093001 = 1.9.30-1. | 97 | * Example: 0x01093001 = 1.9.30-1. |
98 | */ | 98 | */ |
99 | #define MHD_VERSION 0x00097309 | 99 | #define MHD_VERSION 0x00097310 |
100 | 100 | ||
101 | /* If generic headers don't work on your platform, include headers | 101 | /* If generic headers don't work on your platform, include headers |
102 | which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', | 102 | which define 'va_list', 'size_t', 'ssize_t', 'intptr_t', |
@@ -3126,12 +3126,12 @@ enum MHD_ResponseFlags | |||
3126 | * does not implement HTTP/1.1 features, but advertises HTTP/1.1 support. | 3126 | * does not implement HTTP/1.1 features, but advertises HTTP/1.1 support. |
3127 | * @note Available since #MHD_VERSION 0x00097308 | 3127 | * @note Available since #MHD_VERSION 0x00097308 |
3128 | */ | 3128 | */ |
3129 | MHD_RF_HTTP_1_0_COMPATIBLE_STRICT = 1, | 3129 | MHD_RF_HTTP_1_0_COMPATIBLE_STRICT = 1 << 0, |
3130 | /** | 3130 | /** |
3131 | * The same as #MHD_RF_HTTP_1_0_COMPATIBLE_STRICT | 3131 | * The same as #MHD_RF_HTTP_1_0_COMPATIBLE_STRICT |
3132 | * @note Available since #MHD_VERSION 0x00093701 | 3132 | * @note Available since #MHD_VERSION 0x00093701 |
3133 | */ | 3133 | */ |
3134 | MHD_RF_HTTP_VERSION_1_0_ONLY = 1, | 3134 | MHD_RF_HTTP_VERSION_1_0_ONLY = 1 << 0, |
3135 | 3135 | ||
3136 | /** | 3136 | /** |
3137 | * Only respond in HTTP 1.0-mode. | 3137 | * Only respond in HTTP 1.0-mode. |
@@ -3145,19 +3145,27 @@ enum MHD_ResponseFlags | |||
3145 | * as chunked encoding in requests will be supported still). | 3145 | * as chunked encoding in requests will be supported still). |
3146 | * @note Available since #MHD_VERSION 0x00097308 | 3146 | * @note Available since #MHD_VERSION 0x00097308 |
3147 | */ | 3147 | */ |
3148 | MHD_RF_HTTP_1_0_SERVER = 2, | 3148 | MHD_RF_HTTP_1_0_SERVER = 1 << 1, |
3149 | /** | 3149 | /** |
3150 | * The same as #MHD_RF_HTTP_1_0_SERVER | 3150 | * The same as #MHD_RF_HTTP_1_0_SERVER |
3151 | * @note Available since #MHD_VERSION 0x00096000 | 3151 | * @note Available since #MHD_VERSION 0x00096000 |
3152 | */ | 3152 | */ |
3153 | MHD_RF_HTTP_VERSION_1_0_RESPONSE = 2, | 3153 | MHD_RF_HTTP_VERSION_1_0_RESPONSE = 1 << 1, |
3154 | 3154 | ||
3155 | /** | 3155 | /** |
3156 | * Disable sanity check preventing clients from manually | 3156 | * Disable sanity check preventing clients from manually |
3157 | * setting the HTTP content length option. | 3157 | * setting the HTTP content length option. |
3158 | * @note Available since #MHD_VERSION 0x00096702 | 3158 | * @note Available since #MHD_VERSION 0x00096702 |
3159 | */ | 3159 | */ |
3160 | MHD_RF_INSANITY_HEADER_CONTENT_LENGTH = 4 | 3160 | MHD_RF_INSANITY_HEADER_CONTENT_LENGTH = 1 << 2, |
3161 | |||
3162 | /** | ||
3163 | * Enable sending of "Connection: keep-alive" header even for | ||
3164 | * HTTP/1.1 clients when "Keep-Alive" connection is used. | ||
3165 | * Disabled by default for HTTP/1.1 clients as per RFC. | ||
3166 | * @note Available since #MHD_VERSION 0x00097310 | ||
3167 | */ | ||
3168 | MHD_RF_SEND_KEEP_ALIVE_HEADER = 1 << 3 | ||
3161 | } _MHD_FIXED_FLAGS_ENUM; | 3169 | } _MHD_FIXED_FLAGS_ENUM; |
3162 | 3170 | ||
3163 | 3171 | ||
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index d8561251..9cdc06f1 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -1940,7 +1940,8 @@ build_header_response (struct MHD_Connection *connection) | |||
1940 | } | 1940 | } |
1941 | else if (MHD_CONN_USE_KEEPALIVE == c->keepalive) | 1941 | else if (MHD_CONN_USE_KEEPALIVE == c->keepalive) |
1942 | { | 1942 | { |
1943 | if (MHD_HTTP_VER_1_0 == c->http_ver) | 1943 | if ((MHD_HTTP_VER_1_0 == c->http_ver) || |
1944 | (0 != (r->flags | MHD_RF_SEND_KEEP_ALIVE_HEADER))) | ||
1944 | { | 1945 | { |
1945 | if (! buffer_append_s (buf, &pos, buf_size, | 1946 | if (! buffer_append_s (buf, &pos, buf_size, |
1946 | MHD_HTTP_HEADER_CONNECTION ": Keep-Alive\r\n")) | 1947 | MHD_HTTP_HEADER_CONNECTION ": Keep-Alive\r\n")) |
@@ -1954,7 +1955,8 @@ build_header_response (struct MHD_Connection *connection) | |||
1954 | if (! add_user_headers (buf, &pos, buf_size, r, MHD_HEADER_KIND, | 1955 | if (! add_user_headers (buf, &pos, buf_size, r, MHD_HEADER_KIND, |
1955 | ! c->rp_props.chunked, | 1956 | ! c->rp_props.chunked, |
1956 | (MHD_CONN_MUST_CLOSE == c->keepalive), | 1957 | (MHD_CONN_MUST_CLOSE == c->keepalive), |
1957 | (MHD_HTTP_VER_1_0 == c->http_ver) && | 1958 | ((MHD_HTTP_VER_1_0 == c->http_ver) || |
1959 | (0 != (r->flags | MHD_RF_SEND_KEEP_ALIVE_HEADER))) && | ||
1958 | (MHD_CONN_USE_KEEPALIVE == c->keepalive))) | 1960 | (MHD_CONN_USE_KEEPALIVE == c->keepalive))) |
1959 | return MHD_NO; | 1961 | return MHD_NO; |
1960 | 1962 | ||