diff --git a/src/http.zig b/src/http.zig index 512335d714..df00a8038c 100644 --- a/src/http.zig +++ b/src/http.zig @@ -783,7 +783,7 @@ pub fn doRedirect( NewHTTPContext(is_ssl).closeSocket(socket); } else { // we need to clean the client reference before closing the socket because we are going to reuse the same ref in a another request - if (this.isKeepAlivePossible()) { + if (this.isKeepAlivePossible() and !socket.isClosedOrHasError()) { log("Keep-Alive release in redirect", .{}); assert(this.connected_url.hostname.len > 0); ctx.releaseSocket(