Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cohttp-lwt-unix/test/test_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ let write_req expected req =
let make_simple_req () =
let open Cohttp in
let open Cohttp_lwt_unix in
let expected = "POST /foo/bar HTTP/1.1\r\nfoo: bar\r\nhost: localhost\r\ntransfer-encoding: chunked\r\n\r\n6\r\nfoobar\r\n0\r\n\r\n" in
let expected = "POST /foo/bar HTTP/1.1\r\nfoo: bar\r\nhost: localhost\r\ntransfer-encoding: chunked\r\nuser-agent: ocaml-cohttp/\r\n\r\n6\r\nfoobar\r\n0\r\n\r\n" in
let req = Request.make ~encoding:Transfer.Chunked ~meth:`POST ~headers:(Header.init_with "Foo" "bar") (Uri.of_string "/foo/bar") in
write_req expected req

let mutate_simple_req () =
let open Cohttp in
let open Cohttp_lwt_unix in
let expected = "POST /foo/bar HTTP/1.1\r\nfoo: bar\r\nhost: localhost\r\ntransfer-encoding: chunked\r\n\r\n6\r\nfoobar\r\n0\r\n\r\n" in
let expected = "POST /foo/bar HTTP/1.1\r\nfoo: bar\r\nhost: localhost\r\ntransfer-encoding: chunked\r\nuser-agent: ocaml-cohttp/\r\n\r\n6\r\nfoobar\r\n0\r\n\r\n" in
let req = Request.make ~encoding:Transfer.Chunked ~headers:(Header.init_with "foo" "bar") (Uri.of_string "/foo/bar") in
let req = Fieldslib.Field.fset Request.Fields.meth req `POST in
write_req expected req
Expand Down
2 changes: 2 additions & 0 deletions cohttp/src/request.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ let make ?(meth=`GET) ?(version=`HTTP_1_1) ?encoding ?headers uri =
match Uri.port uri with
| Some p -> ":" ^ string_of_int p
| None -> "") in
let headers =
Header.add_unless_exists headers "user-agent" Header.user_agent in
let headers =
(* Add user:password auth to headers from uri
* if headers don't already have auth *)
Expand Down