Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some typo and documentation fixes #1072

Merged
merged 2 commits into from
Jul 9, 2024
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
10 changes: 5 additions & 5 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
## v6.0.0~beta1 (2023-10-27)
- cohttp-eio: move new Cohttp.{Client,Server} modules under Cohttp.Generic (mseri #1003)
- cohttp-eio: Add Client.make_generic and HTTPS support. (talex5 #1002)
- cohttp: move generic client and server signatures to cohttp and use them across all packges. (mefyl #984)
- cohttp: move generic client and server signatures to cohttp and use them across all packages. (mefyl #984)
- cohttp-eio: Complete rewrite to follow common interfaces and behaviors. (mefyl #984)

## v6.0.0~alpha2 (2023-08-08)
Expand Down Expand Up @@ -141,7 +141,7 @@
**Breaking** the headers are no-longer lowercased when parsed, the headers key comparison is case insensitive instead.

- cohttp-lwt-unix: Adopt ocaml-conduit 5.0.0 (smorimoto #787)
**Breaking** `Conduit_lwt_unix.connect`'s `ctx` param type chaged from `ctx` to `ctx Lazy.t`
**Breaking** `Conduit_lwt_unix.connect`'s `ctx` param type changed from `ctx` to `ctx Lazy.t`

- cohttp-mirage: fix deprecated fmt usage (tmcgilchrist #783)
- lwt_jsoo: Use logs for the warnings and document it (mseri #776)
Expand All @@ -161,7 +161,7 @@
- Use implicit executable dependency for generate.exe (TheLortex #735)
- cohttp: fix chunked encoding of empty body (mefyl #715)
- cohttp-async: fix body not being uploaded with unchunked Async.Pipe (mefyl #706)
- cohttp-{async, lwt}: fix suprising behaviours of Body.is_empty (anuragsoni #714 #712 #713)
- cohttp-{async, lwt}: fix surprising behaviours of Body.is_empty (anuragsoni #714 #712 #713)
- refactoring of tests (mseri #709, dinosaure #692)
- update documentation (dinosaure #716, mseri #720)
- fix deadlock in logging (dinosaure #722)
Expand Down Expand Up @@ -273,7 +273,7 @@ Async: Expert response action no longer writes empty HTTP body (#647 by andreas)

In cohttp.0.99, a number of subpackages were turned into explicit
opam packages to simplify dependency management.
To aid migration, some compatability shims were left in place so that
To aid migration, some compatibility shims were left in place so that
the old findlib names would continue to work. They have now been removed
as of this release. If you were still using them, then please rename
them as follows:
Expand Down Expand Up @@ -380,7 +380,7 @@ and avsm.

## 0.22.0 (2017-03-09)

* Lwt: ensure conn_closed is cosed once client goes away (#528)
* Lwt: ensure conn_closed is closed once client goes away (#528)
* Use the Logs library for logging. (#532)

## 0.21.1 (2017-02-18)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ Assuming that the server is running in cohttp's source directory:
$ cohttp-curl-lwt 'http://0.0.0.0:8080/README.md'
```

Other examples using the async api are avaliable in the
Other examples using the async api are available in the
[cohttp-async/examples](https://github.com/mirage/ocaml-cohttp/tree/master/cohttp-async/examples)
folder in the sources.

Expand Down
20 changes: 10 additions & 10 deletions cohttp-async/examples/s3_cp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ module S3 = struct
}
[@@deriving sexp]

let make_request ?body conf ~meth ~bucket ~objekt =
let make_request ?body conf ~meth ~bucket ~object_ =
let host_str = region_host_string conf.region in
let uri =
Printf.sprintf "https://%s/%s/%s" host_str bucket objekt |> Uri.of_string
Printf.sprintf "https://%s/%s/%s" host_str bucket object_ |> Uri.of_string
in
let time = Time.now () in
(* If PUT add content length *)
Expand Down Expand Up @@ -334,16 +334,16 @@ module S3 = struct
| _ -> failwith "not possible right now"
end

type s3path = { bucket : string; objekt : string }
type s3path = { bucket : string; object_ : string }
type cmd = S3toLocal of s3path * string | LocaltoS3 of string * s3path

let determine_s3_parts s =
(* Takes: string of the form s3://<bucket>/<object> *)
(* Takes: string of the form s3://<bucket>/<object_> *)
let s = String.drop_prefix s 5 in
let parts = String.split ~on:'/' s in
match parts with
| bucket :: rst -> { bucket; objekt = String.concat ~sep:"/" rst }
| _ -> failwith "error format must be 's3://<bucket>/<object>'"
| bucket :: rst -> { bucket; object_ = String.concat ~sep:"/" rst }
| _ -> failwith "error format must be 's3://<bucket>/<object_>'"

let determine_paths src dst =
let is_s3 s = String.is_prefix ~prefix:"s3://" s in
Expand All @@ -360,15 +360,15 @@ let main region_str aws_access_key aws_secret_key src dst () =
let conf = { region; aws_access_key; aws_secret_key } in
match determine_paths src dst with
| S3toLocal (src, dst) -> (
make_request conf ~meth:`GET ~bucket:src.bucket ~objekt:src.objekt
make_request conf ~meth:`GET ~bucket:src.bucket ~object_:src.object_
>>= fun (resp, body) ->
match Http.Response.(resp.status) with
| #Http.Status.success ->
Body.to_string body >>| fun s ->
Out_channel.with_file
~f:(fun oc -> Out_channel.output_string oc s)
dst;
Core.Printf.printf "Wrote s3://%s to %s\n" (src.bucket ^ src.objekt)
Core.Printf.printf "Wrote s3://%s to %s\n" (src.bucket ^ src.object_)
dst
| _ ->
Core.Printf.printf "Error: %s\n"
Expand All @@ -378,12 +378,12 @@ let main region_str aws_access_key aws_secret_key src dst () =
let body =
In_channel.with_file src ~f:(fun ic -> In_channel.input_all ic)
in
make_request ~body conf ~meth:`PUT ~bucket:dst.bucket ~objekt:dst.objekt
make_request ~body conf ~meth:`PUT ~bucket:dst.bucket ~object_:dst.object_
>>= fun (resp, body) ->
match Http.Response.status resp with
| #Http.Status.success ->
Core.Printf.printf "Wrote %s to s3://%s\n" src
(dst.bucket ^ dst.objekt);
(dst.bucket ^ dst.object_);
return ()
| _ ->
Body.to_string body >>| fun s ->
Expand Down
2 changes: 1 addition & 1 deletion cohttp-async/src/server.mli
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type response_action =
underlying {!Async_unix.Reader.t} and {!Async_unix.Writer.t}, which allows
writing a response body more efficiently, stream a response or to switch
protocols entirely (e.g. websockets). Processing of pipelined requests
continue after the {!unit Async_kernel.Deferred.t} is resolved. The
continue after the [unit Async_kernel.Deferred.t] is resolved. The
connection can be closed by closing the {!Async_unix.Reader.t}. *)

val respond : response respond_t
Expand Down
2 changes: 1 addition & 1 deletion cohttp-eio/src/client_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module type BASE = sig
(Http.Response.t * Eio.Flow.source_ty r, string) Result.t Io.t)
with_context
(** Send an HTTP request with arbitrary method and a body. If the URI has a
host, we use a TCP connection, otherwaise a UNIX domain socket. *)
host, we use a TCP connection, otherwise a UNIX domain socket. *)
end

module type S = sig
Expand Down
2 changes: 1 addition & 1 deletion cohttp-lwt-jsoo/src/cohttp_lwt_jsoo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ module Make_client_async (P : Params) = Make_api (struct
with
| e
(* If we exhaust the stack, it is possible that
Lwt.wakeup just aboves marks the promise as
Lwt.wakeup just above marks the promise as
completed, but raises Stack_overflow while
running the promise callbacks. In this case
waking calling wakeup_exn on the already
Expand Down
2 changes: 1 addition & 1 deletion cohttp-lwt-unix/src/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exception Isnt_a_file
let respond_file ?headers ~fname () =
Lwt.catch
(fun () ->
(* Check this isnt a directory first *)
(* Check this isn't a directory first *)
( fname |> Lwt_unix.stat >>= fun s ->
if Unix.(s.st_kind <> S_REG) then Lwt.fail Isnt_a_file
else Lwt.return_unit )
Expand Down
2 changes: 1 addition & 1 deletion cohttp-lwt-unix/test/test_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ let test_unknown uri =
in
tests handler uri

(* In that difficult case one might be better of using a Connection_cache which
(* In that difficult case one might be better off using a Connection_cache which
* will take care of those trivial retries and reconnecting: *)

module Cache = Cohttp_lwt_unix.Connection_cache
Expand Down
2 changes: 1 addition & 1 deletion cohttp-lwt-unix/test/test_parser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ let test_cases =
List.map (fun (n, x) -> n >:: fun () -> Lwt_main.run (x ())) tests

(* Returns true if the result list contains successes only.
Copied from ounit2 source as it isnt exposed by the mli *)
Copied from ounit2 source as it isn't exposed by the mli *)
let rec was_successful = function
| [] -> true
| RSuccess _ :: t | RSkip _ :: t -> was_successful t
Expand Down
2 changes: 1 addition & 1 deletion cohttp-lwt/src/connection_cache.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ end = struct
res
end

(** This functor keeps a cache of connecions for reuse. Connections are reused
(** This functor keeps a cache of connections for reuse. Connections are reused
based on their remote {!type:Conduit.endp} (effectively IP / port). *)
module Make (Connection : S.Connection) (Sleep : S.Sleep) : sig
include S.Connection_cache
Expand Down
6 changes: 3 additions & 3 deletions cohttp-lwt/src/s.ml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ type call =
Logs.set_level (Some Logs.Warning)
]}

@raise {!exception:Connection.Retry}
@raise {!Connection.Retry}
on recoverable errors like the remote endpoint closing the connection
gracefully. Even non-idempotent requests are guaranteed to not have been
processed by the remote endpoint and should be retried. But beware that a
Expand Down Expand Up @@ -132,7 +132,7 @@ module type Connection = sig
closed as soon as possible. If [true], it is assumed the remote end does
support pipelining and multiple requests may be sent even before
receiving any reply. By default we wait for the first response to decide
whether connection keep-alive and pipelining is suppored. Chunked
whether connection keep-alive and pipelining is supported. Chunked
encoding can only be used when pipelining is supported. Therefore better
avoid using chunked encoding on the very first request.
@param ctx See [Net.ctx]
Expand Down Expand Up @@ -217,7 +217,7 @@ module type Client = sig
Uri.t ->
(Http.Request.t * Body.t) Lwt_stream.t ->
(Http.Response.t * Body.t) Lwt_stream.t Lwt.t
(** @deprecated use {!module Cohttp_lwt.Connection} instead. *)
(** @deprecated use {!module:Cohttp_lwt.Connection} instead. *)
end

(** The [Server] module implements a pipelined HTTP/1.1 server. *)
Expand Down
6 changes: 3 additions & 3 deletions cohttp-lwt/src/string_io.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

(** Lwt IO implementation that uses strings to marshal and unmarshal HTTP *)

(** IO interface that uses {!buf} for input data and queues output data into a
{!Buffer.t}. Never actually blocks despite the Lwt use, although a future
revision may yield when parsing large strings. *)
(** IO interface that uses {!Cohttp.Private.String_io.buf} for input data and
queues output data into a {!Buffer.t}. Never actually blocks despite the Lwt
use, although a future revision may yield when parsing large strings. *)
include
Cohttp.S.IO
with type 'a t = 'a Lwt.t
Expand Down
2 changes: 1 addition & 1 deletion cohttp-mirage.opam
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
opam-version: "2.0"
synopsis: "CoHTTP implementation for the MirageOS unikernel"
description: """
This HTTP implementation uses the Cohttp portable implementaiton
This HTTP implementation uses the Cohttp portable implementation
along with the Lwt threading library in order to provide a
`Cohttp_mirage` functor that can be used in MirageOS unikernels
to build very small and efficient HTTP clients and servers
Expand Down
2 changes: 1 addition & 1 deletion cohttp-mirage/src/cohttp_mirage.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Net = Net.Make

(** client modules *)

(** simple, high-level interace *)
(** simple, high-level interface *)

module Client = Client

Expand Down
63 changes: 32 additions & 31 deletions cohttp-server-lwt-unix/src/cohttp_server_lwt_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,36 @@
functionality but offers more control and better performance. The
differences are as follows:

- Vastly improved performance due to optimized buffer handling
- No dependency on conduit
- No builtin logging

An example server: {[
open Lwt.Syntax

let server_callback ctx =
Lwt.join
[
Cohttp_server_lwt_unix.ontext.discard_body ctx;
Cohttp_server_lwt_unix.ontext.respond ctx
(Http.Response.make ())
(Cohttp_server_lwt_unix.Body.string "hello world");
]

let main () =
let* _server =
let listen_address = Unix.(ADDR_INET (inet_addr_loopback, 8080)) in
let server = Cohttp_server_lwt_unix.create server_callback in
Lwt_io.establish_server_with_client_address ~backlog:10_000 listen_address
(fun _addr ch -> Cohttp_server_lwt_unix.handle_connection server ch)
in
let forever, _ = Lwt.wait () in
forever

let () = ignore (Lwt_main.run (main ()))
]}
*)
- Vastly improved performance due to optimized buffer handling
- No dependency on conduit
- No builtin logging

An example server:

{[
open Lwt.Syntax

let server_callback ctx =
Lwt.join
[
Cohttp_server_lwt_unix.ontext.discard_body ctx;
Cohttp_server_lwt_unix.ontext.respond ctx (Http.Response.make ())
(Cohttp_server_lwt_unix.Body.string "hello world");
]

let main () =
let* _server =
let listen_address = Unix.(ADDR_INET (inet_addr_loopback, 8080)) in
let server = Cohttp_server_lwt_unix.create server_callback in
Lwt_io.establish_server_with_client_address ~backlog:10_000
listen_address (fun _addr ch ->
Cohttp_server_lwt_unix.handle_connection server ch)
in
let forever, _ = Lwt.wait () in
forever

let () = ignore (Lwt_main.run (main ()))
]} *)

module Body : sig
module Encoding : sig
Expand All @@ -60,7 +61,7 @@ module Body : sig
(** [stream ?encoding f] respond with body generated by repeatedly applying
[f]. When [f] returns [None], it will be considered terminated.

[?encoding] is the encoding to use. By deafult this is [Encoding.chunked]. *)
[?encoding] is the encoding to use. By default this is [Encoding.chunked]. *)
end

module Context : sig
Expand Down Expand Up @@ -88,7 +89,7 @@ val create : ?on_exn:(exn -> unit) -> (Context.t -> unit Lwt.t) -> t
(** [create ?on_exn f] creates an HTTP server that will handle every incoming
request with [f] concurrently.

[on_exn] will be called on exceptions not caught in [f] or raisedd by the
[on_exn] will be called on exceptions not caught in [f] or raised by the
server itself. If [on_exn] isn't provided [Lwt.async_exception_hook] will be
used. *)

Expand Down
2 changes: 1 addition & 1 deletion cohttp/src/code.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type success_status =
| `Partial_content (** partial resource return due to request header *)
| `Multi_status (** XML, can contain multiple separate responses *)
| `Already_reported (** results previously returned *)
| `Im_used (** request fulfilled, reponse is instance-manipulations *) ]
| `Im_used (** request fulfilled, response is instance-manipulations *) ]
[@@deriving sexp]
(** Success *)

Expand Down
2 changes: 1 addition & 1 deletion cohttp/src/connection.mli
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ val create : unit -> t
(** Create a fresh connection identifier. *)

val to_string : t -> string
(** Pretty-print a connection identifer. *)
(** Pretty-print a connection identifier. *)

val compare : t -> t -> int
(** Comparison function for two identifiers. More recently constructed
Expand Down
9 changes: 5 additions & 4 deletions cohttp/src/header.mli
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ val remove : t -> string -> t

val replace : t -> string -> string -> t
(** [replace h k v] replaces the last added value of [k] from [h] and removed
all other occurences of [k] if it exists. Otherwise it adds [(k, v)] to [h].
all other occurrences of [k] if it exists. Otherwise it adds [(k, v)] to
[h].

{e Invariant:} [forall h, k, v. get_multi (replace h k v) = [ v ]] *)

Expand Down Expand Up @@ -124,7 +125,7 @@ val update : t -> string -> (string option -> string option) -> t
except for the header name [k]. Depending on the value of [v] where [v] is
[f (get h k)], the header pair [(k, v)] is added, removed or updated.

- If [v] is [None], the last occurence of [k] in [h] is removed;
- If [v] is [None], the last occurrence of [k] in [h] is removed;

- If [v] is [Some w] then the last value paired with [k] in [h] is replaced
by [w] if it exists. Otherwise, the pair [(k, w)] is added;
Expand All @@ -138,7 +139,7 @@ val update_all : t -> string -> (string list -> string list) -> t
[vs] is [f (get_multi h k)], the values associated to the header [k] are
added, removed or updated.

- If [vs] is an empty list, every occurences of the header [k] in [h] are
- If [vs] is an empty list, every occurrences of the header [k] in [h] are
removed;

- If [vs] is a non-empty list, all values previously associated to [k] are
Expand All @@ -152,7 +153,7 @@ val map : (string -> string -> string) -> t -> t
val fold : (string -> string -> 'a -> 'a) -> t -> 'a -> 'a

val to_lines : t -> string list
(** [to_lines h] returns header fieds as a list of lines. Beware that each line
(** [to_lines h] returns header fields as a list of lines. Beware that each line
ends with "\r\n" characters. *)

val to_frames : t -> string list
Expand Down
5 changes: 3 additions & 2 deletions cohttp/src/request.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

include S.Request with type t = Http.Request.t
(** This contains the metadata for a HTTP/1.x request header, including the
{!headers}, {!version}, {!meth} and {!uri}. The body is handled by the
separate {!S} module type, as it is dependent on the IO implementation.
{!field-headers}, {!field-version}, {!field-meth} and {!field-uri}. The body
is handled by the separate {!S} module type, as it is dependent on the IO
implementation.

The interface exposes a [fieldslib] interface which provides individual
accessor functions for each of the records below. It also provides [sexp]
Expand Down
Loading
Loading