Skip to content

1.2.0

Choose a tag to compare

@matasarei matasarei released this 23 Jul 21:25
· 40 commits to main since this release
197a083

Robustness fixes for the stream handling, opt-in delimiter-based response framing, and modernized tooling.

Added

  • Client::setDelimiter() — optional end-of-response marker (e.g. "\n" for line-based protocols such as JSON-RPC over TCP). With a delimiter set, a response is complete as soon as it ends with the delimiter instead of after a silent interval on the stream: reads return sooner and truncated responses are detected (RequestException on timeout, ConnectionException when the connection closes before the response is completed) rather than silently accepted.
  • Client::setPollInterval() and Client::DEFAULT_POLL_INTERVAL — renamed from "connection lag": the value is the pause between data availability checks.
  • CI: GitHub Actions matrix testing PHP 7.4, 8.0, 8.1, 8.2, 8.3, 8.4 and 8.5.

Fixed

  • Infinite loop on a broken stream: read() looped on fread() !== '', but fread() returns false on error, so a broken stream spun forever. It now throws a ConnectionException.
  • A connection closed by the peer looked like a timeout: neither read loop checked feof(), so a closed connection kept polling for the full request timeout (30 s by default) and then reported a timeout. It now fails fast with ConnectionException.
  • Unchecked and partial writes: request() ignored the fwrite() result, so large request bodies could be partially written with no error surfaced. Writes now continue until the whole body is sent; a zero-byte write (full send buffer in non-blocking mode) is retried until the request timeout.

Changed

  • Default chunk size raised from 1024 to 8192 bytes to match the size of PHP's internal stream read buffer.
  • psr/log v1, v2 and v3 are now accepted (Client::setLogger() returns void per the v3 interface).
  • Minimum PHP version raised from 7.1 to 7.4.
  • Test suite migrated from PHPUnit 7 to PHPUnit 9.6; README rewritten.

Deprecated

  • Client::setConnectionLag() — use setPollInterval() instead.
  • Client::DEFAULT_CONNECTION_LAG — use DEFAULT_POLL_INTERVAL instead.

Removed

  • Unused ext-json requirement from composer.json.

Backward-compatibility notes

  • Wire behaviour without a delimiter is unchanged.
  • A peer-closed connection now throws ConnectionException promptly instead of RequestException after the full timeout — code that caught only RequestException for that case should also catch ConnectionException.

Full Changelog: 1.1...1.2.0