diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-06-13 17:23:19 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-06-13 20:45:46 +0300 |
commit | a60173864e4e50fab7676653cfce04421828cef3 (patch) | |
tree | 9d38fbe1bab9f669a2b409a9c6e00dfc6625bc2a | |
parent | bbbcf4838ae137052e8b8a98f26e14a90c8b420c (diff) | |
download | libmicrohttpd-a60173864e4e50fab7676653cfce04421828cef3.tar.gz libmicrohttpd-a60173864e4e50fab7676653cfce04421828cef3.zip |
MHD_queue_response(): refuse 1xx codes in HTTP/1.0 mode
See https://datatracker.ietf.org/doc/html/rfc7231#section-6.2
-rw-r--r-- | src/microhttpd/connection.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 3d98f917..e274ace5 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -4247,12 +4247,6 @@ MHD_queue_response (struct MHD_Connection *connection, | |||
4247 | { | 4247 | { |
4248 | struct MHD_Daemon *daemon; | 4248 | struct MHD_Daemon *daemon; |
4249 | 4249 | ||
4250 | if ( (NULL == connection) || | ||
4251 | (NULL == response) || | ||
4252 | (NULL != connection->response) || | ||
4253 | ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) && | ||
4254 | (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) ) | ||
4255 | return MHD_NO; | ||
4256 | daemon = connection->daemon; | 4250 | daemon = connection->daemon; |
4257 | 4251 | ||
4258 | if (daemon->shutdown) | 4252 | if (daemon->shutdown) |
@@ -4271,6 +4265,14 @@ MHD_queue_response (struct MHD_Connection *connection, | |||
4271 | return MHD_NO; | 4265 | return MHD_NO; |
4272 | } | 4266 | } |
4273 | #endif | 4267 | #endif |
4268 | |||
4269 | if ( (NULL == connection) || | ||
4270 | (NULL == response) || | ||
4271 | (NULL != connection->response) || | ||
4272 | ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) && | ||
4273 | (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) ) | ||
4274 | return MHD_NO; | ||
4275 | |||
4274 | #ifdef UPGRADE_SUPPORT | 4276 | #ifdef UPGRADE_SUPPORT |
4275 | if ( (NULL != response->upgrade_handler) && | 4277 | if ( (NULL != response->upgrade_handler) && |
4276 | (0 == (daemon->options & MHD_ALLOW_UPGRADE)) ) | 4278 | (0 == (daemon->options & MHD_ALLOW_UPGRADE)) ) |
@@ -4304,6 +4306,31 @@ MHD_queue_response (struct MHD_Connection *connection, | |||
4304 | #endif | 4306 | #endif |
4305 | return MHD_NO; | 4307 | return MHD_NO; |
4306 | } | 4308 | } |
4309 | if (200 > (status_code & (~MHD_ICY_FLAG))) | ||
4310 | { | ||
4311 | if (MHD_HTTP_VER_1_0 == connection->http_ver) | ||
4312 | { | ||
4313 | #ifdef HAVE_MESSAGES | ||
4314 | MHD_DLOG (daemon, | ||
4315 | _ ("Wrong status code (%u) refused. " \ | ||
4316 | "HTTP/1.0 clients do not support 1xx status codes!\n"), | ||
4317 | (status_code & (~MHD_ICY_FLAG))); | ||
4318 | #endif | ||
4319 | return MHD_NO; | ||
4320 | } | ||
4321 | if (0 != response->flags & (MHD_RF_HTTP_VERSION_1_0_ONLY | ||
4322 | | MHD_RF_HTTP_VERSION_1_0_RESPONSE)) | ||
4323 | { | ||
4324 | #ifdef HAVE_MESSAGES | ||
4325 | MHD_DLOG (daemon, | ||
4326 | _ ("Wrong status code (%u) refused. " \ | ||
4327 | "HTTP/1.0 reply mode does not support 1xx status codes!\n"), | ||
4328 | (status_code & (~MHD_ICY_FLAG))); | ||
4329 | #endif | ||
4330 | return MHD_NO; | ||
4331 | } | ||
4332 | } | ||
4333 | |||
4307 | MHD_increment_response_rc (response); | 4334 | MHD_increment_response_rc (response); |
4308 | connection->response = response; | 4335 | connection->response = response; |
4309 | connection->responseCode = status_code; | 4336 | connection->responseCode = status_code; |