diff --git a/cohttp/test/test_request.ml b/cohttp/test/test_request.ml index 0b02feff0..75da8f841 100644 --- a/cohttp/test/test_request.ml +++ b/cohttp/test/test_request.ml @@ -2,6 +2,8 @@ open Cohttp module String_io = Cohttp.Private.String_io module StringRequest = Request.Private.Make (String_io.M) +let user_agent = Cohttp.Header.user_agent + let uri_userinfo = Uri.of_string "http://foo:bar%2525@ocaml.org" let header_auth = @@ -310,21 +312,22 @@ let null_content_length_header () = let () = (* The user-agent in releases contentsontains the version, we need to strip it for the test *) - let headers = Cohttp.Header.of_list [ ("user-agent", "ocaml-cohttp") ] in let r = - Cohttp.Request.make_for_client ~headers ~chunked:false ~body_length:0L + Cohttp.Request.make_for_client ~chunked:false ~body_length:0L `PUT (Uri.of_string "http://someuri.com") in Request.write_header r output - in - Alcotest.(check string) - "null content-length header are sent" - "PUT / HTTP/1.1\r\n\ - user-agent: ocaml-cohttp\r\n\ + in + let expected = "PUT / HTTP/1.1\r\n\ host: someuri.com\r\n\ + user-agent: " ^ user_agent ^ "\r\n\ content-length: 0\r\n\ \r\n" + in + Alcotest.(check string) + "null content-length header are sent" + expected (Buffer.to_string output) let useless_null_content_length_header () = @@ -336,9 +339,14 @@ let useless_null_content_length_header () = in Request.write_header r output in + let expected = "GET / HTTP/1.1\r\n\ + host: someuri.com\r\n\ + user-agent: " ^ user_agent ^ "\r\n\ + \r\n" + in Alcotest.(check string) "null content-length header are not sent for bodyless methods" - "GET / HTTP/1.1\r\nhost: someuri.com\r\nuser-agent: ocaml-cohttp/\r\n\r\n" + expected (Buffer.to_string output) let () =