Skip to content

Support streams with optional endpoints - #45

Open
OskarEichler wants to merge 1 commit into
rack:mainfrom
OskarEichler:songstats/stream-optional-endpoints
Open

Support streams with optional endpoints#45
OskarEichler wants to merge 1 commit into
rack:mainfrom
OskarEichler:songstats/stream-optional-endpoints

Conversation

@OskarEichler

Copy link
Copy Markdown

Rackup::Stream.new currently evaluates an undefined Buffered constant before it can construct the stream. Supplying only an input works around that constant but then forces a writable output, so the nominally optional endpoints are not actually optional. If input is absent, the first read should report EOF; an explicit close_read should still make later reads raise.

Make both endpoints optional, retain validation when output is present, distinguish initial EOF from explicit read closure, and make empty? safe without output.

This ports the relevant source-origin Stream corrections from socketry/protocol-http commit 2c3115e, whose Stream implementation Rackup shares.

Verification:

  • deterministic endpoint/closure model fails on 2.3.1/current and passes this branch
  • full suite: 76 runs / 194 assertions / 0 failures
  • Ruby syntax, warning-mode load, package build and diff checks pass on Ruby 4.0.6
  • combined candidate also passes 74 runs / 182 assertions on Ruby 3.2.11

No breaking change for supplied endpoints; invalid non-writable outputs remain rejected.

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