From d0be587a36ba1532042bd597e5b1de11f320f6b5 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Wed, 6 Jan 2021 23:29:45 +0100 Subject: [PATCH] Bugfix --- src/client.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/client.c b/src/client.c index dcdce56..ffd4884 100644 --- a/src/client.c +++ b/src/client.c @@ -530,6 +530,7 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int http_add_header_field(&res.hdr, "Server", SERVER_STR); } char *conn = http_get_header_field(&res.hdr, "Connection"); + int close_proxy = conn == NULL || strcmp(conn, "keep-alive") != 0; http_remove_header_field(&res.hdr, "Connection", HTTP_REMOVE_ALL); http_remove_header_field(&res.hdr, "Keep-Alive", HTTP_REMOVE_ALL); if (server_keep_alive && client_keep_alive) { @@ -658,15 +659,16 @@ int client_request_handler(sock *client, unsigned long client_num, unsigned int if (ret <= 0) break; } } while (chunked && len_to_send > 0); - if (conn == NULL || strcmp(conn, "keep-alive") != 0) { - print("Closing proxy connection"); - shutdown(rev_proxy_sock, SHUT_RDWR); - close(rev_proxy_sock); - rev_proxy_sock = 0; - } } } + if (close_proxy) { + print("Closing proxy connection"); + shutdown(rev_proxy_sock, SHUT_RDWR); + close(rev_proxy_sock); + rev_proxy_sock = 0; + } + clock_gettime(CLOCK_MONOTONIC, &end); micros = (end.tv_nsec - begin.tv_nsec) / 1000 + (end.tv_sec - begin.tv_sec) * 1000000; print("Transfer complete: %s", format_duration(micros, buf0));