Skip to content

Add a non-blocking partial peek for layered streams - #16

Merged
samuel-williams-shopify merged 9 commits into
mainfrom
fix/tls-viability-probe
Jul 27, 2026
Merged

Add a non-blocking partial peek for layered streams#16
samuel-williams-shopify merged 9 commits into
mainfrom
fix/tls-viability-probe

Conversation

@samuel-williams-shopify

@samuel-williams-shopify samuel-williams-shopify commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add IO::Stream::Readable#peek_partial for one non-blocking read attempt without consuming application data
  • preserve any decoded byte in the stream read buffer
  • mark the stream finished when TLS decodes close_notify
  • return immediately available data, or nil when reading would block or reaches EOF
  • cover clean TLS shutdown, abrupt termination, idle TLS, and buffered application data

HTTP/1 can use this primitive in its protocol-specific connection viability check before reusing an idle connection. This addresses the stale HTTPS connection behavior discussed in socketry/async-http#223 without changing the non-consuming readable? contract used by HTTP/2.

Validation

  • 342 tests passed, 1823 assertions
  • documentation coverage: 82/82
  • RuboCop: 41 files, no offenses
  • focused TLS tests: 4 passed, 9 assertions
  • git diff --check passed

@samuel-williams-shopify samuel-williams-shopify changed the title Detect TLS close notifications when probing readability Add a non-blocking partial peek for layered streams Jul 25, 2026
@samuel-williams-shopify
samuel-williams-shopify merged commit f06105d into main Jul 27, 2026
34 of 40 checks passed
@samuel-williams-shopify
samuel-williams-shopify deleted the fix/tls-viability-probe branch July 27, 2026 03:40
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