diff options
| author | Jo-Philipp Wich | 2024-01-23 08:48:35 +0000 |
|---|---|---|
| committer | Jo-Philipp Wich | 2024-01-23 08:48:35 +0000 |
| commit | b3e3c05d6781caa5db54fc9913772ddc1af2e045 (patch) | |
| tree | c96ae9facda9490bd85536df07eccc3e2f950b49 | |
| parent | 34a8a74dbdec3c0de38abc1b08f6a73c51263792 (diff) | |
client: don't send stray EOF chunk on connection timeout
Ensure that any kind of chunk data is only sent when the client connection
is in the body data state in order to avoid sending superfluous `0\r\n\r\n`
chunks on closing idle connections.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
| -rw-r--r-- | client.c | 4 | ||||
| -rw-r--r-- | utils.c | 4 |
2 files changed, 3 insertions, 5 deletions
@@ -158,10 +158,8 @@ uh_client_error(struct client *cl, int code, const char *summary, const char *fm * interpreted as part of the next request. The alternative * would be to read and discard the request body here. */ - if (r->transfer_chunked || r->content_length > 0) { - cl->state = CLIENT_STATE_CLOSE; + if (r->transfer_chunked || r->content_length > 0) cl->request.connection_close = true; - } uh_request_done(cl); } @@ -56,7 +56,7 @@ void uh_chunk_vprintf(struct client *cl, const char *format, va_list arg) va_list arg2; int len; - if (cl->state == CLIENT_STATE_CLEANUP) + if (cl->state != CLIENT_STATE_DATA) return; uloop_timeout_set(&cl->timeout, conf.network_timeout * 1000); @@ -91,7 +91,7 @@ void uh_chunk_eof(struct client *cl) if (!uh_use_chunked(cl)) return; - if (cl->state == CLIENT_STATE_CLEANUP) + if (cl->state != CLIENT_STATE_DATA) return; ustream_printf(cl->us, "0\r\n\r\n"); |