summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich2024-01-23 08:48:35 +0000
committerJo-Philipp Wich2024-01-23 08:48:35 +0000
commitb3e3c05d6781caa5db54fc9913772ddc1af2e045 (patch)
treec96ae9facda9490bd85536df07eccc3e2f950b49
parent34a8a74dbdec3c0de38abc1b08f6a73c51263792 (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.c4
-rw-r--r--utils.c4
2 files changed, 3 insertions, 5 deletions
diff --git a/client.c b/client.c
index c037cc7..a987867 100644
--- a/client.c
+++ b/client.c
@@ -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);
}
diff --git a/utils.c b/utils.c
index 6502d94..5304c2a 100644
--- a/utils.c
+++ b/utils.c
@@ -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");