Add JavaScript and StringIO backends, and numerous interface improvements
Compatibility breaking interface changes:
- Rename
Cohttp.Auth.t
toCohttp.Auth.credential
andCohttp.Auth.req
toCohttp.Auth.challenge
. Also expose anOther
variant
to make it more extensible for unknown authentication types. The
Cohttp.Auth
functions using these types have also been renamed accordingly. - Rename
Cohttp.Transfer.encoding_to_string
tostring_of_encoding
for consistency with the rest of Cohttp's APIs. - The
has_body
function in the Request and Response modules now
explicitly signals when the body size is unknown. - Move all the module type signatures into
Cohttp.S
. - If users have percent-encoded file names, their resolution is changed:
resolve_local_file
inCohttp_async
andCohttp_lwt
now always
percent-decode paths (#157) - Remove the
Cohttp_lwt.Server.server
type synonym tot
. - When reading data from a HTTP body stream using the
Fixed
encoding,
we need to maintain state (bytes remaining) so we know when to finish.
TheCohttp.Request
andCohttp.Response
interfaces now expose a
reader
andwriter
types to track this safely. - Add
is_empty
function to theCohttp.S.Body
module type. - Add
Strings
representation toCohttp.Body
to efficiently hold a
list of body chunks. - Move flushing logic for HTTP bodies into the portable
Request
and
Response
modules instead of individual Lwt and Async backends. - Port module interfaces to the latest Conduit (0.6.0+) API.
- Cohttp requires OCaml 4.01.0 or higher now.
New features and bugfixes:
- Add a
Cohttp_lwt_xhr
JavaScript backend that enables Cohttp logic to be
mapped toXMLHTTPRequest
in browsers viajs_of_ocaml
(via Andy Ray). - Add a
Cohttp.String_io
andString_io_lwt
module that uses OCaml
string
orBuffer.t
to read and write HTTP requests and responses
instead of network connections. cohttp_server_lwt
andcohttp_server_async
now return better errors (#158)cohttp_server_lwt
andcohttp_server_async
now serve indexes directly (#162)- [lwt] Add
stop
thread to terminate a running server if it finishes (#147). - Add
Cohttp.Connection.compare
to make ordering of connections possible. - Add
Body.map
andBody.as_pipe
to work with HTTP bodies more easily. - Remove link-time dependency on camlp4 via META fixes (#127).
- Support HTTP methods and versions other than the standard ones. (#142).
- Improve
cohttp_server_lwt
andcohttp_server_async
directory listings (#158) - Fix
Cohttp_async.resolve_local_file
directory traversal vulnerability (#158) - [async] In the Async server, do not close the Reader too early.
- [async] Close file descriptors more eagerly in the HTTP client (#167).
- Reduce thread allocation by replacing
return <const>
withreturn_none
,
return_unit
orreturn_nil
.