@@ -12,9 +12,8 @@ module Body = struct
1212 (Transfer. Fixed (Int64. of_int (String. length s)))
1313 (fun write -> write s)
1414
15- let of_cohttp body =
16- ( (fun write -> Cohttp_lwt.Body. write_body write body)
17- , Cohttp_lwt.Body. transfer_encoding body )
15+ let of_cohttp ~encoding body =
16+ (fun write -> Cohttp_lwt.Body. write_body write body), encoding
1817
1918 let write (w , _ ) = w
2019 let transfer_encoding = snd
@@ -26,16 +25,16 @@ type t =
2625let make ?(body = Body. empty) ?(cookies = Ocsigen_cookie_map. empty) a_response =
2726 {a_response; a_body = body; a_cookies = cookies}
2827
29- let respond ?headers ~status ?(body = Body. empty) () =
28+ let respond ?headers ~status ~ encoding ?(body = Body. empty) () =
3029 let encoding =
3130 match headers with
32- | None -> Body. transfer_encoding body
31+ | None -> encoding
3332 | Some headers -> (
3433 match Cohttp.Header. get_transfer_encoding headers with
35- | Cohttp.Transfer. Unknown -> Body. transfer_encoding body
34+ | Cohttp.Transfer. Unknown -> encoding
3635 | t -> t)
3736 in
38- let response = Cohttp. Response. make ~status ~encoding ?headers () in
37+ let response = Response. make ~status ~encoding ?headers () in
3938 make ~body response
4039
4140let respond_string ?headers ~status ~body () =
@@ -57,7 +56,8 @@ let update ?response ?body ?cookies {a_response; a_body; a_cookies} =
5756 {a_response; a_body; a_cookies}
5857
5958let of_cohttp ?(cookies = Ocsigen_cookie_map. empty) (a_response , body ) =
60- let a_body = Body. of_cohttp body in
59+ let encoding = Response. encoding a_response in
60+ let a_body = Body. of_cohttp ~encoding body in
6161 {a_response; a_body; a_cookies = cookies}
6262
6363(* FIXME: secure *)
0 commit comments