| ... | @@ -439,7 +439,14 @@ pub const Response = struct { | ... | @@ -439,7 +439,14 @@ pub const Response = struct { |
| 439 | } | 439 | } |
| 440 | | 440 | |
| 441 | if (!res.headers.contains("connection")) { | 441 | 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 | } |
| 443 | } | 450 | } |
| 444 | | 451 | |
| 445 | const has_transfer_encoding = res.headers.contains("transfer-encoding"); | 452 | const has_transfer_encoding = res.headers.contains("transfer-encoding"); |