Skip to content

Commit

Permalink
cohttp-eio(client): move Host header to the font
Browse files Browse the repository at this point in the history
  • Loading branch information
bikallem committed Sep 15, 2022
1 parent 08e626c commit 4842d2e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cohttp-eio/src/client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ let response buf_read =

let call ?meth ?version ?(headers = Http.Header.init ()) ?(body = Body.Empty)
~conn host resource_path =
let host_hdr = "Host" in
let headers =
if not (Http.Header.mem headers "Host") then
if not (Http.Header.mem headers host_hdr) then
let host =
match host with
| host, Some port -> host ^ ":" ^ string_of_int port
| host, None -> host
in
Http.Header.add headers "Host" host
else headers
Http.Header.add headers host_hdr host
else Http.Header.move_to_front headers host_hdr
in
let request = Http.Request.make ?meth ?version ~headers resource_path in
Buf_write.with_flow ~initial_size:0x1000 conn (fun writer ->
Expand Down

0 comments on commit 4842d2e

Please sign in to comment.