From 638c52eb07d05e6769392c995bf77624f34e2f12 Mon Sep 17 00:00:00 2001 From: Ushitora Anqou Date: Sun, 10 Mar 2024 18:44:17 +0900 Subject: [PATCH] cohttp-lwt: server: return connection header --- cohttp-lwt/src/server.ml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cohttp-lwt/src/server.ml b/cohttp-lwt/src/server.ml index e6fc7678c..386788e42 100644 --- a/cohttp-lwt/src/server.ml +++ b/cohttp-lwt/src/server.ml @@ -146,6 +146,15 @@ module Make (IO : S.IO) = struct let keep_alive = Http.Request.is_keep_alive req && Http.Response.is_keep_alive res in + let res = + let headers = + Http.Header.add_unless_exists + (Http.Response.headers res) + "connection" + (if keep_alive then "keep-alive" else "close") + in + { res with Http.Response.headers } + in handle_response ~keep_alive oc res body (fun () -> spec.conn_closed conn) (fun oc -> handle_client ic oc conn spec)