Resto: Fix #480: Keep the host:
set by the user with TEZOS_SIGNER_HTTP_HEADERS
This is a fixup of 21bb9436371741a8cf643cfc6218ace9ebfecc19
This commit is contained in:
parent
b4b97dada3
commit
d7ba8bb07d
20
vendors/ocplib-resto/lib_resto-cohttp/client.ml
vendored
20
vendors/ocplib-resto/lib_resto-cohttp/client.ml
vendored
@ -144,6 +144,15 @@ module Make (Encoding : Resto.ENCODING) = struct
|
|||||||
}
|
}
|
||||||
|
|
||||||
let internal_call meth (log : log) ?(headers = []) ?accept ?body ?media uri : (content, content) generic_rest_result Lwt.t =
|
let internal_call meth (log : log) ?(headers = []) ?accept ?body ?media uri : (content, content) generic_rest_result Lwt.t =
|
||||||
|
let host =
|
||||||
|
match Uri.host uri, Uri.port uri with
|
||||||
|
| None, _ -> None
|
||||||
|
| Some host, None -> Some host
|
||||||
|
| Some host, Some port -> Some (host ^ ":" ^ string_of_int port) in
|
||||||
|
let init_headers =
|
||||||
|
match host with
|
||||||
|
| None -> Header.init ()
|
||||||
|
| Some host -> Header.replace (Header.init ()) "host" host in
|
||||||
let headers = List.fold_left (fun headers (header, value) ->
|
let headers = List.fold_left (fun headers (header, value) ->
|
||||||
let header = String.lowercase_ascii header in
|
let header = String.lowercase_ascii header in
|
||||||
if header <> "host"
|
if header <> "host"
|
||||||
@ -153,7 +162,7 @@ module Make (Encoding : Resto.ENCODING) = struct
|
|||||||
"Resto_cohttp.Client.call: \
|
"Resto_cohttp.Client.call: \
|
||||||
only headers \"host\" or starting with \"x-\" are supported"
|
only headers \"host\" or starting with \"x-\" are supported"
|
||||||
else Header.replace headers header value)
|
else Header.replace headers header value)
|
||||||
(Header.init ()) headers in
|
init_headers headers in
|
||||||
let body, headers =
|
let body, headers =
|
||||||
match body, media with
|
match body, media with
|
||||||
| None, _ -> Cohttp_lwt.Body.empty, headers
|
| None, _ -> Cohttp_lwt.Body.empty, headers
|
||||||
@ -166,15 +175,6 @@ module Make (Encoding : Resto.ENCODING) = struct
|
|||||||
| None -> headers
|
| None -> headers
|
||||||
| Some ranges ->
|
| Some ranges ->
|
||||||
Header.add headers "accept" (Media_type.accept_header ranges) in
|
Header.add headers "accept" (Media_type.accept_header ranges) in
|
||||||
let host =
|
|
||||||
match Uri.host uri, Uri.port uri with
|
|
||||||
| None, _ -> None
|
|
||||||
| Some host, None -> Some host
|
|
||||||
| Some host, Some port -> Some (host ^ ":" ^ string_of_int port) in
|
|
||||||
let headers =
|
|
||||||
match host with
|
|
||||||
| None -> headers
|
|
||||||
| Some host -> Header.add headers "host" host in
|
|
||||||
Lwt.catch begin fun () ->
|
Lwt.catch begin fun () ->
|
||||||
let rec call_and_retry_on_502 attempt delay =
|
let rec call_and_retry_on_502 attempt delay =
|
||||||
Cohttp_lwt_unix.Client.call
|
Cohttp_lwt_unix.Client.call
|
||||||
|
Loading…
Reference in New Issue
Block a user