Flip set_stream_handler default to auto-replay buffered DATA#5
Merged
Conversation
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.).
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses High audit finding #9:
h2:set_stream_handler/3defaulted todrain_buffer => true, which returned{ok, Buffered}and required the caller to forward each tuple to the handler pid manually. Code that pattern-matched onlyoksilently dropped buffered DATA frames — easy to do because the simple shape ignores the buffered case.drain_buffer => false: the connection replays buffered DATA frames to the handler pid as{h2, Conn, {data, StreamId, Data, Fin}}messages, and the call returnsok.drain_buffer => truestill returns the raw buffer for callers that want it (tests, etc.).@docon both the publich2:set_stream_handler/3,4and the internalh2_connection:set_stream_handler/3,4.set_stream_handler_default_replays_buffer_testuses the simpleok = h2:set_stream_handler(...)shape and confirms the handler still receives early DATA frames.All 94 tests pass.