mirror of
https://github.com/ziglang/zig.git
synced 2026-01-04 12:33:19 +00:00
std.http.Server: use client recommendation for keepalive
This commit is contained in:
parent
71c228fe65
commit
6513eb4696
@ -439,7 +439,14 @@ pub const Response = struct {
|
||||
}
|
||||
|
||||
if (!res.headers.contains("connection")) {
|
||||
try w.writeAll("Connection: keep-alive\r\n");
|
||||
const req_connection = res.request.headers.getFirstValue("connection");
|
||||
const req_keepalive = req_connection != null and !std.ascii.eqlIgnoreCase("close", req_connection.?);
|
||||
|
||||
if (req_keepalive) {
|
||||
try w.writeAll("Connection: keep-alive\r\n");
|
||||
} else {
|
||||
try w.writeAll("Connection: close\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
const has_transfer_encoding = res.headers.contains("transfer-encoding");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user