diff --git a/ocaml/libs/tracing/tracing.ml b/ocaml/libs/tracing/tracing.ml index ef976e95244..a897ab4a0c0 100644 --- a/ocaml/libs/tracing/tracing.ml +++ b/ocaml/libs/tracing/tracing.ml @@ -688,16 +688,26 @@ module Export = struct let export ~url json = try let body = json in - (*If host or port is None it will throw a more meaningful error later, so ignore here*) - let hostname = match Uri.host url with Some h -> h | None -> "" in - let port = match Uri.port url with Some p -> p | None -> 80 in let headers = Cohttp.Header.of_list - [ - ("Content-Type", "application/json") - ; ("Content-Length", string_of_int (String.length body)) - ; ("Host", hostname ^ ":" ^ string_of_int port) - ] + ([ + ("Content-Type", "application/json") + ; ("Content-Length", string_of_int (String.length body)) + ] + @ + match Uri.host url with + | None -> + [] + | Some h -> + let port = + match Uri.port url with + | Some p -> + ":" ^ string_of_int p + | None -> + "" + in + [("Host", h ^ port)] + ) in Open_uri.with_open_uri url (fun fd -> let request =