Skip to content

Commit efd4ec0

Browse files
committed
cohttp-eio(client): move Host header to the font
1 parent 8139c9d commit efd4ec0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## Unreleased
2+
- cohttp-eio: ensure "Host" header is the first header in http client requests (bikallem #939)
23
- cohttp-eio: add Content-Length header to request/response (bikallem #929)
34
- cohttp-eio: add cohttp-eio client api - Cohttp_eio.Client (bikallem #879)
45
- http: add requires_content_length function for requests and responses (bikallem #879)

cohttp-eio/src/client.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,16 @@ let response buf_read =
7272

7373
let call ?meth ?version ?(headers = Http.Header.init ()) ?(body = Body.Empty)
7474
~conn host resource_path =
75+
let host_hdr = "Host" in
7576
let headers =
76-
if not (Http.Header.mem headers "Host") then
77+
if not (Http.Header.mem headers host_hdr) then
7778
let host =
7879
match host with
7980
| host, Some port -> host ^ ":" ^ string_of_int port
8081
| host, None -> host
8182
in
82-
Http.Header.add headers "Host" host
83-
else headers
83+
Http.Header.add headers host_hdr host
84+
else Http.Header.move_to_front headers host_hdr
8485
in
8586
let request = Http.Request.make ?meth ?version ~headers resource_path in
8687
Buf_write.with_flow ~initial_size:0x1000 conn (fun writer ->

0 commit comments

Comments
 (0)