Skip to content

Commit

Permalink
fail earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Nuno Monteiro committed Apr 19, 2019
1 parent 4738cd5 commit 31428cc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 4 additions & 2 deletions lwt/httpaf_lwt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,15 @@ module Server = struct
?(config=Config.default)
~request_handler
~error_handler =
let make_tls_server = Tls_io.make_server ?server ?certfile ?keyfile in
fun client_addr socket ->
let connection =
Server_connection.create
~config
~error_handler:(error_handler client_addr)
(request_handler client_addr)
in
Tls_io.make_server ?server ?certfile ?keyfile socket >>= fun tls_server ->
make_tls_server socket >>= fun tls_server ->
let readf = Tls_io.readf tls_server in
let writev = Tls_io.writev tls_server in
start_read_write_loops ~config ~readf ~writev ~socket connection
Expand All @@ -160,14 +161,15 @@ module Server = struct
?(config=Config.default)
~request_handler
~error_handler =
let make_ssl_server = Ssl_io.make_server ?server ?certfile ?keyfile in
fun client_addr socket ->
let connection =
Server_connection.create
~config
~error_handler:(error_handler client_addr)
(request_handler client_addr)
in
Ssl_io.make_server ?server ?certfile ?keyfile socket >>= fun tls_server ->
make_ssl_server socket >>= fun tls_server ->
let readf = Ssl_io.readf tls_server in
let writev = Ssl_io.writev tls_server in
start_read_write_loops ~config ~readf ~writev ~socket connection
Expand Down
10 changes: 6 additions & 4 deletions lwt/ssl_io_dummy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ let writev _socket _fd =
type client = [ `Ssl_not_available ]
type server = [ `Ssl_not_available ]

let make_client ?client:_ _socket =
Lwt.fail_with "Ssl not available"
let[@ocaml.warning "-21"] make_client ?client:_ =
failwith "Ssl not available";
fun _socket -> Lwt.fail_with "Ssl not available"

let make_server ?server:_ ?certfile:_ ?keyfile:_ _socket =
Lwt.fail_with "Ssl not available"
let[@ocaml.warning "-21"] make_server ?server:_ ?certfile:_ ?keyfile:_ =
failwith "Ssl not available";
fun _socket -> Lwt.fail_with "Ssl not available"
10 changes: 6 additions & 4 deletions lwt/tls_io_dummy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ let writev _tls _fd =
type client = [ `Tls_not_available ]
type server = [ `Tls_not_available ]

let make_client ?client:_ _socket =
Lwt.fail_with "Tls not available"
let[@ocaml.warning "-21"] make_client ?client:_ =
failwith "TLS not available";
fun _socket -> Lwt.return `Tls_not_available

let make_server ?server:_ ?certfile:_ ?keyfile:_ _socket =
Lwt.fail_with "Tls not available"
let[@ocaml.warning "-21"] make_server ?server:_ ?certfile:_ ?keyfile:_ =
failwith "TLS not available";
fun _socket -> Lwt.fail_with "TLS not available"

0 comments on commit 31428cc

Please sign in to comment.