This commit is contained in:
2021-01-06 23:29:45 +01:00
parent 351568004f
commit d0be587a36

View File

@ -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));