mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-06 03:05:29 -05:00
feat ws: expose Close_connection
This commit is contained in:
parent
e4303b2fd4
commit
19554068b5
2 changed files with 5 additions and 6 deletions
|
|
@ -76,12 +76,7 @@ module Writer = struct
|
||||||
Mutex.unlock self.mutex;
|
Mutex.unlock self.mutex;
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
let close self =
|
let[@inline] close self = self.closed <- true
|
||||||
if not self.closed then (
|
|
||||||
self.closed <- true;
|
|
||||||
raise Close_connection
|
|
||||||
)
|
|
||||||
|
|
||||||
let int_of_bool : bool -> int = Obj.magic
|
let int_of_bool : bool -> int = Obj.magic
|
||||||
|
|
||||||
(** Write the frame header to [self.oc] *)
|
(** Write the frame header to [self.oc] *)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,10 @@ type handler = unit Request.t -> IO.Input.t -> IO.Output.t -> unit
|
||||||
val upgrade : IO.Input.t -> IO.Output.t -> IO.Input.t * IO.Output.t
|
val upgrade : IO.Input.t -> IO.Output.t -> IO.Input.t * IO.Output.t
|
||||||
(** Upgrade a byte stream to the websocket framing protocol. *)
|
(** Upgrade a byte stream to the websocket framing protocol. *)
|
||||||
|
|
||||||
|
exception Close_connection
|
||||||
|
(** Exception that can be raised from IOs inside the handler,
|
||||||
|
when the connection is closed from underneath. *)
|
||||||
|
|
||||||
val add_route_handler :
|
val add_route_handler :
|
||||||
?accept:(unit Request.t -> (unit, int * string) result) ->
|
?accept:(unit Request.t -> (unit, int * string) result) ->
|
||||||
?accept_ws_protocol:(string -> bool) ->
|
?accept_ws_protocol:(string -> bool) ->
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue