Skip to content

Commit

Permalink
Merge pull request mirage#996 from mseri/6-alpha2
Browse files Browse the repository at this point in the history
Prepare to release v6.0.0~alpha2
  • Loading branch information
mseri authored Aug 8, 2023
2 parents 6b5202e + bc9c785 commit 2e6474d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
9 changes: 2 additions & 7 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
## Unreleased

## v6.0.0~alpha2 (2023-08-08)
- cohttp-lwt: Do not leak exceptions to `Lwt.async_exception_hook`. (mefyl #992, #995)

## v6.0.0~alpha2 (2023-07-1)
- http.header, cohttp, cohttp-eio: remove "first" and "move_to_first" and the special treatment of the "host" header (mseri #988)
- http.header, cohttp, cohttp-eio: remove "first" and "move_to_first" and the special treatment of the "host" header (mseri #988, #986)
- http.header: introduce "iter_ord" to guarantee iteration following the order of the entries in the headers (mseri #986)
- http.header: fix "move_to_fist" and "first" ro follow Header's semantics (mseri #986)
- cohttp: ensure "host" is the first header (mseri #986)
- do not omit mandatory null Content-Length headers (mefyl #985)
- cohttp-async, cohttp-curl-async: compatibility with core/async v0.16.0 (mseri, dkalinichenko-js #976)
- cohttp-lwt server: call conn_closed before drainig the body of response on error (pirbo #982)
Expand Down
1 change: 0 additions & 1 deletion cohttp-async/examples/s3_cp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
open Base
open Core
open Async

module Time = Time_float

(* open Cohttp *)
Expand Down
7 changes: 3 additions & 4 deletions cohttp-lwt/src/connection_cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ end = struct
>>= fun connection ->
let res = Connection.call connection ?headers ?body meth uri in
(* this can be simplified when https:/mirage/ocaml-conduit/pull/319 is released. *)
Lwt.dont_wait (fun () ->
Lwt.dont_wait
(fun () ->
res >>= fun (_, body) ->
(match body with
| `Empty | `String _ | `Strings _ -> Lwt.return_unit
| `Stream stream -> Lwt_stream.closed stream)
>>= fun () ->
Connection.close connection;
Lwt.return_unit)
(function
| Retry -> ()
| e -> raise e);
(function Retry -> () | e -> raise e);
res
end

Expand Down
26 changes: 14 additions & 12 deletions cohttp/test/test_request.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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%[email protected]"

let header_auth =
Expand Down Expand Up @@ -310,22 +311,19 @@ 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
`PUT
Cohttp.Request.make_for_client ~chunked:false ~body_length:0L `PUT
(Uri.of_string "http://someuri.com")
in
Request.write_header r output
in
let expected =
"PUT / HTTP/1.1\r\nhost: someuri.com\r\nuser-agent: "
^ user_agent
^ "\r\ncontent-length: 0\r\n\r\n"
in
Alcotest.(check string)
"null content-length header are sent"
"PUT / HTTP/1.1\r\n\
user-agent: ocaml-cohttp\r\n\
host: someuri.com\r\n\
content-length: 0\r\n\
\r\n"
(Buffer.to_string output)
"null content-length header are sent" expected (Buffer.to_string output)

let useless_null_content_length_header () =
let output = Buffer.create 1024 in
Expand All @@ -336,9 +334,13 @@ let useless_null_content_length_header () =
in
Request.write_header r output
in
let expected =
"GET / HTTP/1.1\r\nhost: someuri.com\r\nuser-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"
"null content-length header are not sent for bodyless methods" expected
(Buffer.to_string output)

let () =
Expand Down

0 comments on commit 2e6474d

Please sign in to comment.