Skip to content

Commit 94c9239

Browse files
committed
fix(response): do not override "content-length" in raw response
close #92
1 parent c55e3a2 commit 94c9239

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/core/response.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ let set_code code self = { self with code }
1515
let make_raw ?(headers = []) ~code body : t =
1616
(* add content length to response *)
1717
let headers =
18-
Headers.set "Content-Length" (string_of_int (String.length body)) headers
18+
if Headers.contains "content-length" headers then
19+
(* do not override user-provided headers (e.g. in HEAD), see #92 *)
20+
headers
21+
else
22+
Headers.set "Content-Length" (string_of_int (String.length body)) headers
1923
in
2024
{ code; headers; body = `String body }
2125

0 commit comments

Comments
 (0)