Skip to content
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
2 changes: 1 addition & 1 deletion cohttp-async/bin/cohttp_curl_async.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let _ =
Logs.set_level @@ Some Logs.Debug;
Logs.set_reporter (Logs_fmt.reporter ());
let open Command.Spec in
Command.async ~summary:"Fetch URL and print it"
Command.async_spec ~summary:"Fetch URL and print it"
(empty
+> anon ("url" %: string)
+> flag "-X" (optional_with_default "GET" string)
Expand Down
4 changes: 2 additions & 2 deletions cohttp-async/bin/cohttp_server_async.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ let start_server docroot port index cert_file key_file verbose () =
Logs.err (fun f -> f "Error from %s" (Socket.Address.to_string addr));
Logs.err (fun f -> f "%s" @@ Exn.to_string exn)))
~mode
(Tcp.on_port port)
(Tcp.Where_to_listen.of_port port)
(handler ~info ~docroot ~index) >>= fun _serv ->
Deferred.never ()

let () =
let open Command in
run @@
async ~summary:"Serve the local directory contents via HTTP or HTTPS"
async_spec ~summary:"Serve the local directory contents via HTTP or HTTPS"
Spec.(
empty
+> anon (maybe_with_default "." ("docroot" %: string))
Expand Down
4 changes: 2 additions & 2 deletions cohttp-async/src/io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ let read_line =
)

let read ic len =
let buf = String.create len in
let buf = Bytes.create len in
Reader.read ic ~len buf >>| function
| `Ok len' -> String.sub buf ~pos:0 ~len:len'
| `Ok len' -> Bytes.To_string.sub buf ~pos:0 ~len:len'
| `Eof -> ""

let write =
Expand Down
6 changes: 3 additions & 3 deletions cohttp-async/src/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ let respond_with_file ?flush ?headers ?(error_body=error_body_default) filename
|Ok res -> return res
|Error _exn -> respond_string ~status:`Not_found error_body

let create ?max_connections ?buffer_age_limit ?on_handler_error
?(mode=`TCP) where_to_listen handle_request =
let create ?max_connections ?buffer_age_limit ?(mode=`TCP)
~on_handler_error where_to_listen handle_request =
Conduit_async.serve ?max_connections
?buffer_age_limit ?on_handler_error mode
?buffer_age_limit ~on_handler_error mode
where_to_listen (handle_client handle_request)
>>| fun server ->
{ server }
6 changes: 3 additions & 3 deletions cohttp-async/src/server.mli
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ val respond_with_file :
val create :
?max_connections:int ->
?buffer_age_limit: Writer.buffer_age_limit ->
?on_handler_error:[ `Call of 'address -> exn -> unit
| `Ignore
| `Raise ] ->
?mode:Conduit_async.server ->
on_handler_error:[ `Call of 'address -> exn -> unit
| `Ignore
| `Raise ] ->
('address, 'listening_on) Tcp.Where_to_listen.t
-> (body:Body.t -> 'address -> Request.t -> response Deferred.t)
-> ('address, 'listening_on) t Deferred.t