- macos-latest
- ubuntu-latest
ocaml-compiler:
- - 4.08.x
- - 4.09.x
- - 4.10.x
- - 4.11.x
- - 4.12.x
+ - 4.14.x
runs-on: ${{ matrix.os }}
+## v5.3.0 (2023-07-21)
+
+- cohttp-async: support for base/async v0.16
+
## v5.2.0 (2023-07-07)
- cohttp-lwt server: call conn_closed before drainig the body of response on error (pirbo)
-version: "5.2.0"
+version: "5.3.0"
opam-version: "2.0"
maintainer: "anil@recoil.org"
authors: [
doc: "https://mirage.github.io/ocaml-cohttp/"
bug-reports: "https://github.com/mirage/ocaml-cohttp/issues"
depends: [
- "ocaml" {>= "4.08"}
+ "ocaml" {>= "4.14"}
"dune" {>= "2.0"}
- "async_kernel" {>= "v0.14.0"}
- "async_unix" {>= "v0.14.0"}
- "async" {>= "v0.14.0" & < "v0.16.0"}
- "base" {>= "v0.11.0"}
- "core" {with-test & < "v0.15.0"}
- "core_unix" {>= "v0.14.0"}
+ "async_kernel" {>= "v0.16.0"}
+ "async_unix" {>= "v0.16.0"}
+ "async" {>= "v0.16.0"}
+ "base" {>= "v0.16.0"}
+ "core" {with-test}
+ "core_unix" {>= "v0.16.0"}
"cohttp" {= version}
"conduit-async" {>= "1.2.0"}
"magic-mime"
| `No | `Unknown ->
(* Do a directory listing *)
Sys.ls_dir file_name
- >>= Deferred.List.map ~f:(fun f ->
+ >>= Deferred.List.map ~how:`Parallel ~f:(fun f ->
let file_name = file_name / f in
try_with (fun () ->
Unix.stat file_name >>| fun stat ->
match body with
| `Empty -> return ()
| `String s -> write_body writer s
- | `Strings sl -> Deferred.List.iter sl ~f:(write_body writer)
+ | `Strings sl -> Deferred.List.iter ~how:`Sequential sl ~f:(write_body writer)
| `Pipe p -> Pipe.iter p ~f:(write_body writer)
let pipe_of_body read_chunk ic =
Connection.connect ?interrupt ?ssl_config uri >>| fun connection ->
let responses =
Pipe.map' ~max_queue_length:1 reqs ~f:(fun reqs ->
- Deferred.Queue.map reqs ~f:(fun (req, body) ->
+ Deferred.Queue.map ~how:`Sequential reqs ~f:(fun (req, body) ->
Connection.request ~body connection req))
in
Pipe.closed responses
open Async_kernel
module Writer = Async_unix.Writer
module Reader = Async_unix.Reader
-module Format = Caml.Format
+module Format = Stdlib.Format
let log_src_name = "cohttp.async.io"
let src = Logs.Src.create log_src_name ~doc:"Cohttp Async IO module"
k ()
in
msgf @@ fun ?header:_ ?tags:_ fmt ->
- Format.kfprintf k fmtr Caml.("@[" ^^ fmt ^^ "@]@.")
+ Format.kfprintf k fmtr Stdlib.("@[" ^^ fmt ^^ "@]@.")
in
{ Logs.report }
Logs.set_reporter (default_reporter ()))
let check_debug norm_fn debug_fn =
- match Caml.Sys.getenv "COHTTP_DEBUG" with
+ match Stdlib.Sys.getenv "COHTTP_DEBUG" with
| _ ->
Lazy.force set_log;
debug_fn
- | exception Caml.Not_found -> norm_fn
+ | exception Stdlib.Not_found -> norm_fn
type 'a t = 'a Deferred.t
reqs |> Pipe.of_list |> Client.callv uri >>= fun responses ->
responses |> Pipe.to_list >>= fun resps ->
resps
- |> Deferred.List.iter ~f:(fun (_resp, body) ->
+ |> Deferred.List.iter ~how:`Sequential ~f:(fun (_resp, body) ->
let expected_body = body_q |> Queue.dequeue_exn in
body |> Body.to_string >>| fun body ->
assert_equal ~printer expected_body body)
("Pipe with empty strings", Pipe.of_list [ ""; ""; "" ], true);
]
in
- Deferred.List.iter tests ~f:(fun (msg, pipe, expected) ->
+ Deferred.List.iter ~how:`Sequential tests ~f:(fun (msg, pipe, expected) ->
is_empty (`Pipe pipe) >>| fun real ->
assert_equal ~msg expected real)
>>= fun () ->
-version: "5.2.0"
+version: "5.3.0"
opam-version: "2.0"
maintainer: "anil@recoil.org"
authors: [
-version: "5.2.0"
+version: "5.3.0"
opam-version: "2.0"
maintainer: "anil@recoil.org"
authors: [
-version: "5.2.0"
+version: "5.3.0"
opam-version: "2.0"
maintainer: "anil@recoil.org"
authors: [
-version: "5.2.0"
+version: "5.3.0"
opam-version: "2.0"
maintainer: "anil@recoil.org"
authors: ["Anil Madhavapeddy" "Thomas Gazagnaire"]
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * cohttp v5.2.0
+ * cohttp v5.3.0
*)
open Lwt.Infix
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * cohttp v5.2.0
+ * cohttp v5.3.0
*)
open Lwt.Infix
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * cohttp v5.2.0
+ * cohttp v5.3.0
*)
(** Cohttp IO implementation using Mirage channels. *)
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * cohttp v5.2.0
+ * cohttp v5.3.0
*)
module Key = Mirage_kv.Key
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * cohttp v5.2.0
+ * cohttp v5.3.0
*)
(** Serve static HTTP sites from a Mirage key-value store. *)
-version: "5.2.0"
+version: "5.3.0"
opam-version: "2.0"
maintainer: "anil@recoil.org"
authors: [
-version: "5.2.0"
+version: "5.3.0"
opam-version: "2.0"
maintainer: "anil@recoil.org"
authors: [
Buffer.contents buf
let parse_error fmt =
- Printf.kprintf
+ Printf.ksprintf
(fun msg ->
Printf.eprintf "parse error: %s\n" msg;
exit 1)
(lang dune 2.0)
(name cohttp)
-(version v5.2.0)
+(version v5.3.0)
(executables
- (names hello_world receive_post)
- (libraries mirage-crypto cohttp-async base async_kernel))
+ (names hello_world receive_post s3_cp)
+ (libraries mirage-crypto cohttp-async base async_kernel core_unix.command_unix))
(alias
(name runtest)
| _ -> Server.respond_string ~status:`Not_found "Route not found"
let start_server port () =
- Caml.Printf.eprintf "Listening for HTTP on port %d\n" port;
- Caml.Printf.eprintf "Try 'curl http://localhost:%d/test?hello=xyz'\n%!" port;
+ Stdlib.Printf.eprintf "Listening for HTTP on port %d\n" port;
+ Stdlib.Printf.eprintf "Try 'curl http://localhost:%d/test?hello=xyz'\n%!" port;
Cohttp_async.Server.create ~on_handler_error:`Raise
(Async.Tcp.Where_to_listen.of_port port)
handler
(optional_with_default 8080 int)
~doc:"int Source port to listen on")
start_server
- |> Command.run
+ |> Command_unix.run
(* compile with: $ corebuild receive_post.native -pkg cohttp.async *)
let start_server port () =
- Caml.Printf.eprintf "Listening for HTTP on port %d\n" port;
- Caml.Printf.eprintf "Try 'curl -X POST -d 'foo bar' http://localhost:%d\n"
+ Stdlib.Printf.eprintf "Listening for HTTP on port %d\n" port;
+ Stdlib.Printf.eprintf "Try 'curl -X POST -d 'foo bar' http://localhost:%d\n"
port;
Cohttp_async.Server.create ~on_handler_error:`Raise
(Async.Tcp.Where_to_listen.of_port port) (fun ~body _ req ->
match req |> Cohttp.Request.meth with
| `POST ->
Body.to_string body >>= fun body ->
- Caml.Printf.eprintf "Body: %s" body;
+ Stdlib.Printf.eprintf "Body: %s" body;
Server.respond `OK
| _ -> Server.respond `Method_not_allowed)
>>= fun _ -> Deferred.never ()
(optional_with_default 8080 int)
~doc:"int Source port to listen on")
start_server
- |> Command.run
+ |> Command_unix.run
open Cohttp
open Cohttp_async
+module Time = Time_float
+
let ksrt (k, _) (k', _) = String.compare k k'
module Compat = struct
+> anon ("src" %: string)
+> anon ("dst" %: string))
main
- |> run
+ |> Command_unix.run