Skip to content

1.3.0

Choose a tag to compare

@matasarei matasarei released this 06 Sep 23:52
· 7 commits to main since this release

Added

  • Client::setMaxResponseSize() and Client::DEFAULT_MAX_RESPONSE_SIZE — a response is now
    capped at 8 MiB by default and throws a RequestException beyond it. Pass null for the
    previous unlimited behaviour.
  • StreamSocket and FSocket take a second constructor argument, $blocking. The first
    argument now only sets the read timeout; previously it decided both, so a positive timeout
    forced a blocking stream. Defaults keep the old behaviour.

Fixed

  • Security: neither transport pinned a scheme, so a host such as udp://127.0.0.1 opened a
    UDP socket. StreamSocket and FSocket now build a tcp:// address and reject a host
    containing :// with a SocketException.
  • Security: the read timeout was only checked when a read came back empty, so a peer that
    kept sending was never timed out and the response grew until the process ran out of memory.
    The elapsed time is now checked on every iteration.
  • The debug log carried the whole Request object, putting the request body — credentials
    included — into the consumer's log. It now carries the body length.
  • Client::connect() accepts a float timeout. It had no parameter type and passed the value
    to an int parameter, so connect(0.5) became 0 and raised an implicit-conversion
    deprecation on PHP 8.1+.
  • A read no longer takes twice the timeout: the clock started after the initial wait had already
    returned, so the wait and the read loop each got a full one. The remaining overshoot is the
    socket's own read timeout, since the elapsed check sits before a blocking fread().
  • phpunit.xml no longer sets stopOnFailure, so a failing run reports every failure.

Changed

  • Package renamed from matasarei/phptcp to matasarei/php-tcp, and the repository renamed to
    match — install with composer require matasarei/php-tcp. The PHP namespace Matasar\PhpTcp
    is unchanged, so no code changes are required. Packagist serves the whole tag history under the
    new name, so 1.0, 1.1 and 1.2.0 resolve there too, even though their own composer.json still
    carries the old one.
  • The no-response exception message is now Request timeout, no response. — it previously
    carried a stray backslash. Code matching on that string needs updating.
  • StreamSocket and FSocket type their first constructor argument as int; a value that is
    not an integer now raises a TypeError instead of being coerced. Same for
    Client::connect(), which is now float and no longer accepts null.