diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-09-29 17:49:02 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2021-09-29 20:44:56 +0300 |
commit | 85afdbaf90d645532b0eeb07d33c7c6f1b5b960f (patch) | |
tree | ad143f74c0a416cb516ec7a4cba4fcde88648f93 /src | |
parent | ccd75de5b8513c5d78d5304ccc318b32b25a1844 (diff) | |
download | libmicrohttpd-85afdbaf90d645532b0eeb07d33c7c6f1b5b960f.tar.gz libmicrohttpd-85afdbaf90d645532b0eeb07d33c7c6f1b5b960f.zip |
transmit_error_response(): check whether it is still possible to send a response
Diffstat (limited to 'src')
-rw-r--r-- | src/microhttpd/connection.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c index 941b21a3..2f8f211c 100644 --- a/src/microhttpd/connection.c +++ b/src/microhttpd/connection.c | |||
@@ -2209,6 +2209,26 @@ transmit_error_response_len (struct MHD_Connection *connection, | |||
2209 | return; | 2209 | return; |
2210 | } | 2210 | } |
2211 | connection->stop_with_error = true; | 2211 | connection->stop_with_error = true; |
2212 | #ifdef HAVE_MESSAGES | ||
2213 | MHD_DLOG (connection->daemon, | ||
2214 | _ ("Error processing request (HTTP response code is %u ('%s')). " \ | ||
2215 | "Closing connection.\n"), | ||
2216 | status_code, | ||
2217 | message); | ||
2218 | #endif | ||
2219 | if (MHD_CONNECTION_START_REPLY < connection->state) | ||
2220 | { | ||
2221 | #ifdef HAVE_MESSAGES | ||
2222 | MHD_DLOG (connection->daemon, | ||
2223 | _ ("Too late to send an error response, " \ | ||
2224 | "response is being sent already.\n"), | ||
2225 | status_code, | ||
2226 | message); | ||
2227 | #endif | ||
2228 | CONNECTION_CLOSE_ERROR (connection, | ||
2229 | _ ("Too late for error response.")); | ||
2230 | return; | ||
2231 | } | ||
2212 | /* TODO: remove when special error queue function is implemented */ | 2232 | /* TODO: remove when special error queue function is implemented */ |
2213 | connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED; | 2233 | connection->state = MHD_CONNECTION_FULL_REQ_RECEIVED; |
2214 | if (0 != connection->read_buffer_size) | 2234 | if (0 != connection->read_buffer_size) |
@@ -2221,13 +2241,6 @@ transmit_error_response_len (struct MHD_Connection *connection, | |||
2221 | 0); | 2241 | 0); |
2222 | connection->read_buffer_size = 0; | 2242 | connection->read_buffer_size = 0; |
2223 | } | 2243 | } |
2224 | #ifdef HAVE_MESSAGES | ||
2225 | MHD_DLOG (connection->daemon, | ||
2226 | _ ( | ||
2227 | "Error processing request (HTTP response code is %u (`%s')). Closing connection.\n"), | ||
2228 | status_code, | ||
2229 | message); | ||
2230 | #endif | ||
2231 | if (NULL != connection->response) | 2244 | if (NULL != connection->response) |
2232 | { | 2245 | { |
2233 | MHD_destroy_response (connection->response); | 2246 | MHD_destroy_response (connection->response); |