Skip to content

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

Open
samuel-williams-shopify wants to merge 8 commits into
mainfrom
fix/tls-viability-probe
Open

Add a non-blocking partial peek for layered streams#16
samuel-williams-shopify wants to merge 8 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
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