From f32c3b39f10e24440526078e218949a52954f3a1 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Thu, 11 Sep 2025 22:44:05 -0400 Subject: [PATCH] disable keep-alive if svr sends Connection: close servers may have a limit on the number of keep-alive requests before closing a connection and siege should be prepared to handle receiving Connection: close from server. --- src/browser.c | 2 +- src/http.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/browser.c b/src/browser.c index e84fb29..0247e16 100644 --- a/src/browser.c +++ b/src/browser.c @@ -583,7 +583,7 @@ __http(BROWSER this, URL U) /** * close the socket and free memory. */ - if (!my.keepalive) { + if (!my.keepalive || !this->conn->connection.reuse) { socket_close(this->conn); } diff --git a/src/http.c b/src/http.c index 7284488..3295fe5 100644 --- a/src/http.c +++ b/src/http.c @@ -480,6 +480,8 @@ http_read_headers(CONN *C, URL U, FACTS facts) } if (strncasecmp(line, CONNECTION, strlen(CONNECTION)) == 0) { response_set_connection(resp, line); + if (response_get_connection(resp) == CLOSE) + C->connection.reuse = 0; } if (strncasecmp(line, "keep-alive: ", 12) == 0) { if (response_set_keepalive(resp, line) == TRUE) {