Skip to content

Commit

Permalink
WebSocket: allow non-FIN frames
Browse files Browse the repository at this point in the history
Since anmonteiro/httpun-ws#33, websocket/af
supports sending frames without the FIN bit. Begin using this in Dream.

See also #181.
  • Loading branch information
aantron committed Nov 10, 2023
1 parent aaabf4d commit a2cfbf4
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/http/shared/websocket.ml
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,13 @@ let websocket_handler stream socket =
let rec outgoing_loop () =
Stream.read
stream
~data:(fun buffer offset length binary _fin ->
(* Until https://github.com/anmonteiro/websocketaf/issues/33. *)
(* if not fin then
websocket_log.error (fun log ->
log "Non-FIN frames not yet supported"); *)
~data:(fun buffer offset length binary fin ->
let kind = if binary then `Binary else `Text in
if !closed then
close !close_code
else begin
Websocketaf.Wsd.schedule socket ~kind buffer ~off:offset ~len:length;
Websocketaf.Wsd.schedule
socket ~is_fin:fin ~kind buffer ~off:offset ~len:length;
bytes_since_flush := !bytes_since_flush + length;
if !bytes_since_flush >= 4096 then
flush ~close outgoing_loop
Expand Down

0 comments on commit a2cfbf4

Please sign in to comment.