Skip to content

Honor output buffers for zero-length stream reads - #44

Open
OskarEichler wants to merge 1 commit into
rack:mainfrom
OskarEichler:songstats/stream-zero-read-buffer
Open

Honor output buffers for zero-length stream reads#44
OskarEichler wants to merge 1 commit into
rack:mainfrom
OskarEichler:songstats/stream-zero-read-buffer

Conversation

@OskarEichler

Copy link
Copy Markdown

Rackup::Stream::Reader#read(0, buffer) should follow the documented IO-like contract: clear and return the caller's buffer without touching input. The current early return instead leaves the buffer stale and returns a different UTF-8 string. Without a buffer it also returns a frozen UTF-8 literal rather than a mutable binary string consistent with other reads.

Return the cleared caller buffer when provided, otherwise a new ASCII-8BIT string.

This ports the corresponding source-origin corrections from socketry/protocol-http commits ee2318e and 479d0bf, whose Stream implementation Rackup shares.

Verification:

  • deterministic buffer/encoding 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 API change; this restores the documented contract.

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