authorgravatar for truemedian@gmail.comNameless <truemedian@gmail.com> 2023-04-27 20:25:46-05:00
committergravatar for truemedian@gmail.comNameless <truemedian@gmail.com> 2023-05-06 21:35:15-05:00
log6513eb4696551a91e322fe2d9879335cd73c92db
tree4a093160376b47ec0269ab7e0c5ace5f7431d3b4
parent71c228fe6572b9f3b30e82035bf8fd7e2b1dd29d
signaturelock-open Commit is signed but in an unrecognized format.

std.http.Server: use client recommendation for keepalive


1 files changed, 8 insertions(+), 1 deletions(-)

lib/std/http/Server.zig+8-1
......@@ -439,7 +439,14 @@ pub const Response = struct {
439439 }
440440
441441 if (!res.headers.contains("connection")) {
442 try w.writeAll("Connection: keep-alive\r\n");
442 const req_connection = res.request.headers.getFirstValue("connection");
443 const req_keepalive = req_connection != null and !std.ascii.eqlIgnoreCase("close", req_connection.?);
444
445 if (req_keepalive) {
446 try w.writeAll("Connection: keep-alive\r\n");
447 } else {
448 try w.writeAll("Connection: close\r\n");
449 }
443450 }
444451
445452 const has_transfer_encoding = res.headers.contains("transfer-encoding");