Skip to content

Flip set_stream_handler default to auto-replay buffered DATA#5

Merged
benoitc merged 1 commit into
mainfrom
flip-set-stream-handler-default
May 19, 2026
Merged

Flip set_stream_handler default to auto-replay buffered DATA#5
benoitc merged 1 commit into
mainfrom
flip-set-stream-handler-default

Conversation

@benoitc
Copy link
Copy Markdown
Owner

@benoitc benoitc commented May 19, 2026

Summary

Addresses High audit finding #9: h2:set_stream_handler/3 defaulted to drain_buffer => true, which returned {ok, Buffered} and required the caller to forward each tuple to the handler pid manually. Code that pattern-matched only ok silently dropped buffered DATA frames — easy to do because the simple shape ignores the buffered case.

  • Default is now drain_buffer => false: the connection replays buffered DATA frames to the handler pid as {h2, Conn, {data, StreamId, Data, Fin}} messages, and the call returns ok.
  • Explicit drain_buffer => true still returns the raw buffer for callers that want it (tests, etc.).
  • Updated @doc on both the public h2:set_stream_handler/3,4 and the internal h2_connection:set_stream_handler/3,4.
  • New CT test set_stream_handler_default_replays_buffer_test uses the simple ok = h2:set_stream_handler(...) shape and confirms the handler still receives early DATA frames.

All 94 tests pass.

Previously drain_buffer defaulted to true: registering a handler on a
stream that had already received DATA returned {ok, Buffered}, and the
caller had to forward each tuple to the handler pid by hand. Code that
pattern-matched only `ok' silently dropped those frames — easy to do
because the simple shape ignores the buffered case.

Flip the default: drain_buffer defaults to false, so the connection
replays buffered frames to the handler pid itself and the call returns
ok. Explicit drain_buffer=>true still returns the raw buffer for
callers that want it (tests, etc.).
@benoitc benoitc merged commit b707887 into main May 19, 2026
5 checks passed
@benoitc benoitc deleted the flip-set-stream-handler-default branch May 19, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant