Skip to content

Commit

Permalink
Some documentation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterDA committed Jul 9, 2024
1 parent b7372ed commit 1de8b77
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 42 deletions.
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
4 changes: 2 additions & 2 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 @@ -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
59 changes: 30 additions & 29 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 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
9 changes: 5 additions & 4 deletions cohttp/src/response.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

include S.Response with type t = Http.Response.t
(** This contains the metadata for a HTTP/1.1 response header, including the
{!encoding}, {!headers}, {!version}, {!status} code and whether to {!flush}
the connection after every body chunk (useful for server-side events and
other long-lived connection protocols). The body is handled by the separate
{!S} module type, as it is dependent on the IO implementation.
{!field-encoding}, {!field-headers}, {!field-version}, {!field-status} code
and whether to flush the connection after every body chunk (useful for
server-side events and other long-lived connection protocols). 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
2 changes: 1 addition & 1 deletion cohttp/src/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module type S = sig
underlying {!IO.ic} and {!IO.oc}, 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 IO.t} is resolved. The connection can be closed by closing the
[unit IO.t] is resolved. The connection can be closed by closing the
{!IO.ic}. *)

type t
Expand Down

0 comments on commit 1de8b77

Please sign in to comment.