mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-05 19:00:32 -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;
|
||||
raise e
|
||||
|
||||
let close self =
|
||||
if not self.closed then (
|
||||
self.closed <- true;
|
||||
raise Close_connection
|
||||
)
|
||||
|
||||
let[@inline] close self = self.closed <- true
|
||||
let int_of_bool : bool -> int = Obj.magic
|
||||
|
||||
(** 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
|
||||
(** 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 :
|
||||
?accept:(unit Request.t -> (unit, int * string) result) ->
|
||||
?accept_ws_protocol:(string -> bool) ->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue