mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
fix(response): do not override "content-length" in raw response
close #92
This commit is contained in:
parent
c55e3a2dfc
commit
94c9239d64
1 changed files with 5 additions and 1 deletions
|
|
@ -15,7 +15,11 @@ let set_code code self = { self with code }
|
||||||
let make_raw ?(headers = []) ~code body : t =
|
let make_raw ?(headers = []) ~code body : t =
|
||||||
(* add content length to response *)
|
(* add content length to response *)
|
||||||
let headers =
|
let headers =
|
||||||
Headers.set "Content-Length" (string_of_int (String.length body)) headers
|
if Headers.contains "content-length" headers then
|
||||||
|
(* do not override user-provided headers (e.g. in HEAD), see #92 *)
|
||||||
|
headers
|
||||||
|
else
|
||||||
|
Headers.set "Content-Length" (string_of_int (String.length body)) headers
|
||||||
in
|
in
|
||||||
{ code; headers; body = `String body }
|
{ code; headers; body = `String body }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue