diff --git a/cohttp/src/request.ml b/cohttp/src/request.ml index 4733401ef..87d56d44c 100644 --- a/cohttp/src/request.ml +++ b/cohttp/src/request.ml @@ -52,12 +52,11 @@ let make ?(meth = `GET) ?(version = `HTTP_1_1) ?encoding let port () = match Uri.port uri with | Some p -> ":" ^ string_of_int p - | None -> ( + | None when meth = `CONNECT -> ( match Uri_services.tcp_port_of_uri uri with - | None when meth = `CONNECT -> - failwith "A port is required for the CONNECT method." - | None -> "" + | None -> failwith "A port is required for the CONNECT method." | Some p -> ":" ^ string_of_int p) + | None -> "" in let host = match Header.get headers "host" with