-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deduplicate code for interfaces (#13)
- Loading branch information
1 parent
2291d7b
commit d8f64e8
Showing
6 changed files
with
83 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
open Httpaf | ||
|
||
module type IO = sig | ||
type socket | ||
type addr | ||
|
||
(** The region [[off, off + len)] is where read bytes can be written to *) | ||
val read | ||
: socket | ||
-> Bigstringaf.t | ||
-> off:int | ||
-> len:int | ||
-> [ `Eof | `Ok of int ] Lwt.t | ||
|
||
val writev | ||
: socket | ||
-> Faraday.bigstring Faraday.iovec list | ||
-> [ `Closed | `Ok of int ] Lwt.t | ||
|
||
val shutdown_send : socket -> unit | ||
|
||
val shutdown_receive : socket -> unit | ||
|
||
val close : socket -> unit Lwt.t | ||
end | ||
|
||
module type Server = sig | ||
type socket | ||
|
||
type addr | ||
|
||
val create_connection_handler | ||
: ?config : Config.t | ||
-> request_handler : (addr -> Server_connection.request_handler) | ||
-> error_handler : (addr -> Server_connection.error_handler) | ||
-> addr | ||
-> socket | ||
-> unit Lwt.t | ||
end | ||
|
||
module type Client = sig | ||
type t | ||
|
||
type socket | ||
|
||
val create_connection | ||
: ?config : Config.t | ||
-> socket | ||
-> t Lwt.t | ||
|
||
val request | ||
: t | ||
-> Request.t | ||
-> error_handler : Client_connection.error_handler | ||
-> response_handler : Client_connection.response_handler | ||
-> [`write] Body.t | ||
|
||
val shutdown: t -> unit | ||
|
||
val is_closed : t -> bool | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters