The combined changelog for all ReactPHP components.
Feature: Improve PHP 8.4+ support by avoiding implicitly nullable types.
(#537 by @clue)
Feature: Allow underscore character in Uri host.
(#524 by @lulhum)
Improve test suite to fix expected error code when ext-sockets is not enabled.
(#539 by @WyriHaximus)
Feature: Improve PHP 8.4+ support by avoiding implicitly nullable type declarations.
(#179 by @clue)
Fix: Fix drain
event of ThroughStream
to handle potential race condition.
(#171 by @clue)
Feature: Improve performance by avoiding unneeded references in FiberMap
.
(#88 by @clue)
Feature: Improve PHP 8.4+ support by avoiding implicitly nullable type declarations.
(#87 by @clue)
Improve type safety for test environment.
(#86 by @SimonFrings)
Feature: Improve PHP 8.4+ support by avoiding implicitly nullable type declarations.
(#260 by @Ayesh)
Feature: Include previous exceptions when reporting unhandled promise rejections.
(#262 by @clue)
Update test suite to improve PHP 8.4+ support.
(#261 by @SimonFrings)
Feature: Add new PSR-7 implementation and remove dated RingCentral PSR-7 dependency.
(#518, #519, #520 and #522 by @clue)
This changeset allows us to maintain our own PSR-7 implementation and reduce
dependencies on external projects. It also improves performance slightly and
does not otherwise affect our public API. If you want to explicitly install
the old RingCentral PSR-7 dependency, you can still install it like this:
composer require ringcentral/psr7
Feature: Add new Uri
class for new PSR-7 implementation.
(#521 by @clue)
Feature: Validate outgoing HTTP message headers and reject invalid messages.
(#523 by @clue)
Fix: Fix HTTP client to omit Transfer-Encoding: chunked
when streaming empty request body.
(#516 by @clue)
Fix: Ensure connection close handler is cleaned up for each request.
(#515 by @WyriHaximus)
Update test suite and avoid unhandled promise rejections.
(#501 and #502 by @clue)
Feature: Full PHP 8.3 compatibility.
(#217 by @sergiy-petrov)
Update test environment and avoid unhandled promise rejections.
(#215, #216 and #218 by @clue)
Feature: Add Promise v3 template types for all public functions.
(#40 by @WyriHaximus and @clue)
All our public APIs now use Promise v3 template types to guide IDEs and static
analysis tools (like PHPStan), helping with proper type usage and improving
code quality:
assertType('bool', await(resolve(true)));
assertType('PromiseInterface<bool>', async(fn(): bool => true)());
assertType('PromiseInterface<bool>', coroutine(fn(): bool => true));
Update test suite to avoid unhandled promise rejections.
(#79 by @clue)
This release contains backported features from the Async v4.2.0 release for those
not yet on PHP 8.1+. Async v3 provides a compatible API, but may not take advantage
of newer language features. We encourage upgrading to the latest version when possible.
Feature: Add Promise v3 template types for all public functions.
(#82 by @WyriHaximus and @clue)
All our public APIs now use Promise v3 template types to guide IDEs and static
analysis tools (like PHPStan), helping with proper type usage and improving
code quality:
assertType('bool', await(resolve(true)));
assertType('PromiseInterface<bool>', coroutine(fn(): bool => true));
Update test suite to avoid unhandled promise rejections.
(#80 by @clue)
This is a compatibility release to ensure a smooth upgrade path for those not yet
on Async v4 or v3. We encourage upgrading to the latest version when possible, as
Async v4 will be the way forward for this project.
Feature: Describe all callable arguments with types for Promise
and Deferred
.
(#253 by @clue)
Update test suite and minor documentation improvements.
(#251 by @ondrejmirtes and #250 by @SQKo)
This is a compatibility release to ensure a smooth upgrade path for those not yet
on Promise v3. We encourage upgrading to the latest version when possible, as
Promise v3 will be the way forward for this project.
This is a compatibility release to ensure a smooth upgrade path for those not
yet on Promise v3. We encourage upgrading to the latest version when possible,
as Promise v3 will be the way forward for this project.
Improve test suite, use GitHub actions for continuous integration (CI) and
report failed assertions.
(#242 by @clue and #175, #184, #187, #216 and #218 by @SimonFrings)
Feature: Improve performance by using spl_object_id()
on PHP 7.2+.
(#267 by @samsonasik)
Update tests for ext-uv
on PHP 8+ and legacy PHP.
(#270 by @clue and #268 by @SimonFrings)
Feature: Improve Promise v3 support and use template types.
(#307 and #309 by @clue)
Improve test suite and update to collect all garbage cycles.
(#308 by @clue)
Feature: Use Promise v3 template types.
(#67 by @clue and #63 and #64 by @WyriHaximus)
Improve test suite, avoid unhandled promise rejections and report failed assertions.
(#66 and #62 by @clue and #61 by @WyriHaximus)
A major new feature release, see release announcement.
We'd like to emphasize that this component is production ready and battle-tested.
We plan to support all long-term support (LTS) releases for at least 24 months,
so you have a rock-solid foundation to build on top of.
The v3 release will be the way forward for this package. However, we will still
actively support v2 and v1 to provide a smooth upgrade path for those not yet
on the latest versions.
This update involves some major new features and a minor BC break over the
v2.0.0
release. We've tried hard to avoid BC breaks where possible and
minimize impact otherwise. We expect that most consumers of this package will be
affected by BC breaks, but updating should take no longer than a few minutes.
See below for more details:
BC break: PHP 8.1+ recommended, PHP 7.1+ required.
(#138 and #149 by @WyriHaximus)
Feature / BC break: The PromiseInterface
now includes the functionality of the old and ExtendedPromiseInterface
.CancellablePromiseInterface
Each promise now always includes the then()
, catch()
, finally()
and cancel()
methods.
The new catch()
and finally()
methods replace the deprecated and otherwise()
methods which continue to exist for BC reasons.always()
The old and ExtendedPromiseInterface
are no longer needed and have been removed as a consequence.CancellablePromiseInterface
(#75 by @jsor and #208 by @clue and @WyriHaximus)
// old (multiple interfaces may or may not be implemented)
assert($promise instanceof PromiseInterface);
assert(method_exists($promise, 'then'));
if ($promise instanceof ExtendedPromiseInterface) { assert(method_exists($promise, 'otherwise')); }
if ($promise instanceof ExtendedPromiseInterface) { assert(method_exists($promise, 'always')); }
if ($promise instanceof CancellablePromiseInterface) { assert(method_exists($promise, 'cancel')); }
// new (single PromiseInterface with all methods)
assert($promise instanceof PromiseInterface);
assert(method_exists($promise, 'then'));
assert(method_exists($promise, 'catch'));
assert(method_exists($promise, 'finally'));
assert(method_exists($promise, 'cancel'));
Feature / BC break: Improve type safety of promises. Require mixed
fulfillment value argument and Throwable
(or Exception
) as rejection reason.
Add PHPStan template types to ensure strict types for resolve(T $value): PromiseInterface<T>
and reject(Throwable $reason): PromiseInterface<never>
.
It is no longer possible to resolve a promise without a value (use null
instead) or reject a promise without a reason (use Throwable
instead).
(#93, #141 and #142 by @jsor, #138, #149 and #247 by @WyriHaximus and #213 and #246 by @clue)
// old (arguments used to be optional)
$promise = resolve();
$promise = reject();
// new (already supported before)
$promise = resolve(null);
$promise = reject(new RuntimeException());
Feature / BC break: Report all unhandled rejections by default and remove method.done()
Add new set_rejection_handler()
function to set the global rejection handler for unhandled promise rejections.
(#248, #249 and #224 by @clue)
// Unhandled promise rejection with RuntimeException: Unhandled in example.php:2
reject(new RuntimeException('Unhandled'));
BC break: Remove all deprecated APIs and reduce API surface.
Remove , some()
, map()
functions, use reduce()
any()
and all()
functions instead.
Remove internal and FulfilledPromise
classes, use RejectedPromise
resolve()
and reject()
functions instead.
Remove legacy promise progress API (deprecated third argument to then()
method) and deprecated class.LazyPromise
(#32 and #98 by @jsor and #164, #219 and #220 by @clue)
BC break: Make all classes final to encourage composition over inheritance.
(#80 by @jsor)
Feature / BC break: Require array
(or iterable
) type for all()
+ race()
+ any()
functions and bring in line with ES6 specification.
These functions now require a single argument with a variable number of promises or values as input.
(#225 by @clue and #35 by @jsor)
Fix / BC break: Fix race()
to return a forever pending promise when called with an empty array
(or iterable
) and bring in line with ES6 specification.
(#83 by @jsor and #225 by @clue)
Minor performance improvements by initializing Deferred
in the constructor and avoiding call_user_func()
calls.
(#151 by @WyriHaximus and #171 by @Kubo2)
Minor documentation improvements.
(#110 by @seregazhuk, #132 by @CharlotteDunois, #145 by @danielecr, #178 by @WyriHaximus, #189 by @SrDante, #212 by @clue, #214, #239 and #243 by @SimonFrings and #231 by @nhedger)
The following changes had to be ported to this release due to our branching
strategy, but also appeared in the 2.x
branch:
Feature: Support union types and address deprecation of ReflectionType::getClass()
(PHP 8+).
(#197 by @cdosoftei and @SimonFrings)
Feature: Support intersection types (PHP 8.1+).
(#209 by @bzikarsky)
Feature: Port all memory improvements from 2.x
to 3.x
.
(#150 by @clue and @WyriHaximus)
Fix: Fix checking whether cancellable promise is an object and avoid possible warning.
(#161 by @smscr)
Improve performance by prefixing all global functions calls with \ to skip the look up and resolve process and go straight to the global function.
(#134 by @WyriHaximus)
Improve test suite, update PHPUnit and PHP versions and add .gitattributes
to exclude dev files from exports.
(#107 by @carusogabriel, #148 and #234 by @WyriHaximus, #153 by @reedy, #162, #230 and #240 by @clue, #173, #177, #185 and #199 by @SimonFrings, #193 by @woodongwong and #210 by @bzikarsky)
The following changes were originally planned for this release but later reverted
and are not part of the final release:
Add iterative callback queue handler to avoid recursion (later removed to improve Fiber support).
(#28, #82 and #86 by @jsor, #158 by @WyriHaximus and #229 and #238 by @clue)
Trigger an E_USER_ERROR
instead of throwing an exception from done()
(later removed entire done()
method to globally report unhandled rejections).
(#97 by @jsor and #224 and #248 by @clue)
Add type declarations for some()
(later removed entire some()
function).
(#172 by @WyriHaximus and #219 by @clue)
Feature: Update unwrapped stream to avoid unhandled promise rejections.
(#37 by @clue)
Feature: Improve first()
promise resolution to clean up any garbage references.
(#36 by @lucasnetau)
Improve test suite and project setup and report failed assertions.
(#34 by @clue and #35 by @WyriHaximus)
Feature: Add new delay()
function to delay program execution.
(#69 and #78 by @clue)
echo 'a';
Loop::addTimer(1.0, function () {
echo 'b';
});
React\Async\delay(3.0);
echo 'c';
// prints "a" at t=0.0s
// prints "b" at t=1.0s
// prints "c" at t=3.0s
Update test suite, add PHPStan with max
level and report failed assertions.
(#66 and #76 by @clue and #61 and #73 by @WyriHaximus)
Feature: Add new delay()
function to delay program execution.
(#71 by @clue)
echo 'a';
Loop::addTimer(1.0, function () {
echo 'b';
});
React\Async\delay(3.0);
echo 'c';
// prints "a" at t=0.0s
// prints "b" at t=1.0s
// prints "c" at t=3.0s
Update test suite, add PHPStan with max
level and report failed assertions.
(#67 and #77 by @clue and #60 and #74 by @WyriHaximus)
Feature: Add new delay()
function to delay program execution.
(#72 by @clue)
echo 'a';
Loop::addTimer(1.0, function () {
echo 'b';
});
React\Async\delay(3.0);
echo 'c';
// prints "a" at t=0.0s
// prints "b" at t=1.0s
// prints "c" at t=3.0s
Update test suite, run tests on PHP 8.2 and report failed assertions.
(#59 and #75 by @WyriHaximus and #68 by @clue)
Feature: Full PHP 8.1 and PHP 8.2 compatibility.
(#160 by @SimonFrings, #165 by @clue and #169 by @WyriHaximus)
Feature: Avoid unneeded syscall when creating non-blocking DuplexResourceStream
.
(#164 by @clue)
Minor documentation improvements.
(#161 by @mrsimonbennett, #162 by @SimonFrings and #166 by @nhedger)
Improve test suite and project setup and report failed assertions.
(#168 and #170 by @clue and #163 by @SimonFrings)
Feature: Include timeout logic to avoid dependency on reactphp/promise-timer.
(#305 by @clue)
Feature: Improve errno detection for failed connections without ext-sockets
.
(#304 by @clue)
Improve test suite, clean up leftover .sock
files and report failed assertions.
(#299, #300, #301 and #306 by @clue)
Feature: Include timeout logic to avoid dependency on reactphp/promise-timer.
(#213 by @clue)
Improve test suite and project setup and report failed assertions.
(#210 by @clue, #212 by @WyriHaximus and #209 and #211 by @SimonFrings)
Feature: Improve performance of Loop
by avoiding unneeded method calls.
(#266 by @clue)
Feature: Support checking EINTR
constant from ext-pcntl
without ext-sockets
.
(#265 by @clue)
Improve test suite, run tests on PHP 8.2 and report failed assertions.
(#258 by @WyriHaximus, #264 by @clue and #251, #261 and #262 by @SimonFrings)
Feature: Support Disjunctive Normal Form Types (DNF types) for PHP 8.2+.
(#237 by @nhedger)
Feature: Add full support for PHP 8.2.
(#233 by @WyriHaximus and #241 by @clue)
Improve test suite and project setup and report failed assertions.
(#215 and #217 by @SimonFrings and #241 by @clue)
This is a SECURITY and feature release for the 1.x series of ReactPHP's HTTP component.
Security fix: This release fixes a medium severity security issue in ReactPHP's HTTP server component
that affects all versions between v0.8.0
and v1.8.0
. All users are encouraged to upgrade immediately.
(CVE-2023-26044 reported and fixed by @WyriHaximus)
Feature: Support HTTP keep-alive for HTTP client (reusing persistent connections).
(#481, #484, #486 and #495 by @clue)
This feature offers significant performance improvements when sending many
requests to the same host as it avoids recreating the underlying TCP/IP
connection and repeating the TLS handshake for secure HTTPS requests.
$browser = new React\Http\Browser();
// Up to 300% faster! HTTP keep-alive is enabled by default
$response = React\Async\await($browser->get('https://httpbingo.org/redirect/6'));
assert($response instanceof Psr\Http\Message\ResponseInterface);
Feature: Add Request
class to represent outgoing HTTP request message.
(#480 by @clue)
Feature: Preserve request method and body for 307 Temporary Redirect
and 308 Permanent Redirect
.
(#442 by @dinooo13)
Feature: Include buffer logic to avoid dependency on reactphp/promise-stream.
(#482 by @clue)
Improve test suite and project setup and report failed assertions.
(#478 by @clue, #487 and #491 by @WyriHaximus and #475 and #479 by @SimonFrings)
Feature: Add support for PHP 8.1 and PHP 8.2.
(#44 by @SimonFrings and #51 by @WyriHaximus)
Feature: Forward compatibility with upcoming Promise v3.
(#33 by @WyriHaximus)
Feature / Fix: Improve error reporting when custom error handler is used.
(#49 by @clue)
Improve documentation and examples and update to use new reactphp/async package.
(#50 by @nhedger, #53 by @dinooo13 and #47, #54 and #56 by @SimonFrings)
Improve test suite and report failed assertions.
(#48 by @SimonFrings and #55 by @clue)
Feature: Support PHP 8.1 and PHP 8.2.
(#47 by @SimonFrings and #52 by @WyriHaximus)
Minor documentation improvements.
(#48 by @SimonFrings and #51 by @nhedger)
Update test suite and use GitHub actions for continuous integration (CI).
(#45 and #49 by @SimonFrings and #54 by @clue)
Feature: Support for default request headers.
(#461 by @51imyy)
$browser = new React\Http\Browser();
$browser = $browser->withHeader('User-Agent', 'ACME');
$browser->get($url)->then(…);
Feature: Forward compatibility with upcoming Promise v3.
(#460 by @clue)
Feature: Full support for PHP 8.1 and PHP 8.2 release.
(#91 by @SimonFrings and #99 by @WyriHaximus)
Feature / Fix: Improve error reporting when custom error handler is used.
(#94 by @clue)
Minor documentation improvements.
(#92 by @SimonFrings and #95 by @nhedger)
Improve test suite, skip failing tests on bugged versions and fix legacy HHVM build.
(#96 and #98 by @clue and #93 by @SimonFrings)
Feature: Full support for PHP 8.2 release.
(#33 by @WyriHaximus)
Improve test suite and minor documentation improvements.
(#32 by @clue and #31 by @nhedger)
Feature: Full support for PHP 8.2 release.
(#201 by @clue and #207 by @WyriHaximus)
Feature: Optimize forward compatibility with Promise v3, avoid hitting autoloader.
(#202 by @clue)
Feature / Fix: Improve error reporting when custom error handler is used.
(#197 by @clue)
Fix: Fix invalid references in exception stack trace.
(#191 by @clue)
Minor documentation improvements.
(#195 by @SimonFrings and #203 by @nhedger)
Improve test suite, update to use default loop and new reactphp/async package.
(#204, #205 and #206 by @clue and #196 by @SimonFrings)
Feature: Forward compatibility with react/promise 3.
(#214 by @WyriHaximus and @clue)
Feature: Full support for PHP 8.2 release.
(#298 by @WyriHaximus)
Feature: Avoid unneeded syscall on socket close.
(#292 by @clue)
Feature / Fix: Improve error reporting when custom error handler is used.
(#290 by @clue)
Fix: Fix invalid references in exception stack trace.
(#284 by @clue)
Minor documentation improvements, update to use new reactphp/async package instead of clue/reactphp-block.
(#296 by @clue, #285 by @SimonFrings and #295 by @nhedger)
Improve test suite, update macOS and HHVM environment, fix optional tests for ENETUNREACH
.
(#288, #289 and #297 by @clue)
This is a SECURITY and feature release for the 1.x series of ReactPHP's HTTP component.
Security fix: This release fixes a medium severity security issue in ReactPHP's HTTP server component
that affects all versions between v0.7.0
and v1.6.0
. All users are encouraged to upgrade immediately.
Special thanks to Marco Squarcina (TU Wien) for reporting this and working with us to coordinate this release.
(CVE-2022-36032 reported by @lavish and fixed by @clue)
Feature: Improve HTTP server performance by ~20%, reuse syscall values for clock time and socket addresses.
(#457 and #467 by @clue)
Feature: Full PHP 8.2+ compatibility, refactor internal Transaction
to avoid assigning dynamic properties.
(#459 by @clue and #466 by @WyriHaximus)
Feature / Fix: Allow explicit Content-Length
response header on HEAD
requests.
(#444 by @mrsimonbennett)
Minor documentation improvements.
(#452 by @clue, #458 by @nhedger, #448 by @jorrit and #446 by @SimonFrings)
Improve test suite, update to use new reactphp/async package instead of clue/reactphp-block,
skip memory tests when lowering memory limit fails and fix legacy HHVM build.
(#464 and #440 by @clue and #450 by @SimonFrings)
A major new feature release, see release announcement.
We'd like to emphasize that this component is production ready and battle-tested.
We plan to support all long-term support (LTS) releases for at least 24 months,
so you have a rock-solid foundation to build on top of.
The v4 release will be the way forward for this package. However, we will still
actively support v3 and v2 to provide a smooth upgrade path for those not yet
on PHP 8.1+. If you're using an older PHP version, you may use either version
which all provide a compatible API but may not take advantage of newer language
features. You may target multiple versions at the same time to support a wider range of
PHP versions:
4.x
branch (PHP 8.1+)3.x
branch (PHP 7.1+)2.x
branch (PHP 5.3+)This update involves some major new features and a minor BC break over the
v3.0.0
release. We've tried hard to avoid BC breaks where possible and
minimize impact otherwise. We expect that most consumers of this package will be
affected by BC breaks, but updating should take no longer than a few minutes.
See below for more details:
Feature / BC break: Require PHP 8.1+ and add mixed
type declarations.
(#14 by @clue)
Feature: Add Fiber-based async()
and await()
functions.
(#15, #18, #19 and #20 by @WyriHaximus and #26, #28, #30, #32, #34, #55 and #57 by @clue)
Project maintenance, rename main
branch to 4.x
and update installation instructions.
(#29 by @clue)
The following changes had to be ported to this release due to our branching
strategy, but also appeared in the v3.0.0
release:
Feature: Support iterable type for parallel()
+ series()
+ waterfall()
.
(#49 by @clue)
Feature: Forward compatibility with upcoming Promise v3.
(#48 by @clue)
Minor documentation improvements.
(#36 by @SimonFrings and #51 by @nhedger)
A major new feature release, see release announcement.
We'd like to emphasize that this component is production ready and battle-tested.
We plan to support all long-term support (LTS) releases for at least 24 months,
so you have a rock-solid foundation to build on top of.
The v4 release will be the way forward for this package. However, we will still
actively support v3 and v2 to provide a smooth upgrade path for those not yet
on PHP 8.1+. If you're using an older PHP version, you may use either version
which all provide a compatible API but may not take advantage of newer language
features. You may target multiple versions at the same time to support a wider range of
PHP versions:
4.x
branch (PHP 8.1+)3.x
branch (PHP 7.1+)2.x
branch (PHP 5.3+)This update involves some major new features and a minor BC break over the
v2.0.0
release. We've tried hard to avoid BC breaks where possible and
minimize impact otherwise. We expect that most consumers of this package will be
affected by BC breaks, but updating should take no longer than a few minutes.
See below for more details:
Feature / BC break: Require PHP 7.1+ and add type declarations.
(#11 by @clue)
Feature: Add Generator-based coroutine()
function.
(#12, #13 and #54 by @clue)
Feature: Support iterable type for parallel()
+ series()
+ waterfall()
.
(#45 by @clue)
The following changes had to be ported to this release due to our branching
strategy, but also appeared in the v2.0.0
release:
Feature: Only stop loop for await()
if a pending promise resolves/rejects.
(#33 by @SimonFrings)
Feature: Forward compatibility with upcoming Promise v3.
(#47 by @clue)
Minor documentation improvements.
(#37 by @SimonFrings and #52 by @nhedger)
A major new feature release, see release announcement.
We'd like to emphasize that this component is production ready and battle-tested.
We plan to support all long-term support (LTS) releases for at least 24 months,
so you have a rock-solid foundation to build on top of.
The v4 release will be the way forward for this package. However, we will still
actively support v3 and v2 to provide a smooth upgrade path for those not yet
on PHP 8.1+. If you're using an older PHP version, you may use either version
which all provide a compatible API but may not take advantage of newer language
features. You may target multiple versions at the same time to support a wider range of
PHP versions:
4.x
branch (PHP 8.1+)3.x
branch (PHP 7.1+)2.x
branch (PHP 5.3+)This update involves some major changes over the previous v1.0.0
release that
has been deprecated since 2013. Accordingly, most consumers of this package
should not be affected by any BC breaks. See below for more details:
Feature / BC break: Change to Promise-based APIs instead of callbacks (continuation-passing style).
Support promise cancellation and upcoming Promise v3.
(#6, #7, #9 and #46 by @clue)
Feature: Add new await()
function (import from clue/reactphp-block).
(#8 by @clue and #39 by @SimonFrings)
Minor documentation improvements.
(#38 by @SimonFrings and #53 by @nhedger)
Improve test suite and add .gitattributes
to exclude dev files from exports.
Run tests on PHP 8.1, PHPUnit 9, switch to GitHub actions and clean up test suite.
(#2, #3, #4, #5 and #10 by @clue)
Feature: Forward compatibility with react/promise 3.
(#20 by @WyriHaximus)
Improve test suite, test against PHP 8.1 and fix legacy HHVM build.
(#28, #29 and #30 by @SimonFrings)
Feature: Improve forward compatibility with upcoming Promise v3 API.
(#54 and #55 by @clue)
Minor documentation improvements for upcoming Promise v3.
(#58 by @clue and #56 by @SimonFrings)
Improve test suite, fix legacy HHVM build by downgrading Composer.
(#57 by @SimonFrings)
Feature: Improve default StreamSelectLoop
to report any warnings for invalid streams.
(#245 by @clue)
Feature: Improve performance of StreamSelectLoop
when no timers are scheduled.
(#246 by @clue)
Fix: Fix periodic timer with zero interval for ExtEvLoop
and legacy ExtLibevLoop
.
(#243 by @lucasnetau)
Minor documentation improvements, update PHP version references.
(#240, #248 and #250 by @SimonFrings, #241 by @dbu and #249 by @clue)
Improve test suite and test against PHP 8.1.
(#238 by @WyriHaximus and #242 by @clue)
Feature: Support union types and address deprecation of ReflectionType::getClass()
(PHP 8+).
(#198 by @cdosoftei and @SimonFrings)
$promise->otherwise(function (OverflowException|UnderflowException $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
Feature: Support intersection types (PHP 8.1+).
(#195 by @bzikarsky)
$promise->otherwise(function (OverflowException&CacheException $e) {
echo 'Error: ' . $e->getMessage() . PHP_EOL;
});
Improve test suite, use GitHub actions for continuous integration (CI),
update to PHPUnit 9, and add full core team to the license.
(#174, #183, #186, and #201 by @SimonFrings and #211 by @clue)
Feature: Add factory methods for common HTML/JSON/plaintext/XML response types.
(#439 by @clue)
$response = React\Http\Response\html("<h1>Hello wörld!</h1>\n");
$response = React\Http\Response\json(['message' => 'Hello wörld!']);
$response = React\Http\Response\plaintext("Hello wörld!\n");
$response = React\Http\Response\xml("<message>Hello wörld!</message>\n");
Feature: Expose all status code constants via Response
class.
(#432 by @clue)
$response = new React\Http\Message\Response(
React\Http\Message\Response::STATUS_OK, // 200 OK
…
);
$response = new React\Http\Message\Response(
React\Http\Message\Response::STATUS_NOT_FOUND, // 404 Not Found
…
);
Feature: Full support for PHP 8.1 release.
(#433 by @SimonFrings and #434 by @clue)
Feature / Fix: Improve protocol handling for HTTP responses with no body.
(#429 and #430 by @clue)
Internal refactoring and internal improvements for handling requests and responses.
(#422 by @WyriHaximus and #431 by @clue)
Improve documentation, update proxy examples, include error reporting in examples.
(#420, #424, #426, and #427 by @clue)
Improve test suite to skip FD test when hitting memory limit
and skip legacy TLS 1.0 tests if disabled by system.
(#278 and #281 by @clue and #283 by @SimonFrings)
Feature: Full support for PHP 8.1 release and prepare PHP 8.2 compatibility
by refactoring Parser
to avoid assigning dynamic properties.
(#188 and #186 by @clue and #184 by @SimonFrings)
Feature / Fix: Skip invalid nameserver entries from resolv.conf
and ignore IPv6 zone IDs.
(#187 by @clue)
Feature / Fix: Reduce socket read chunk size for queries over TCP/IP.
(#189 by @clue)
Feature: Add new sleep()
function and deprecate resolve()
and reject()
functions.
(#51 by @clue)
// deprecated
React\Promise\Timer\resolve($time);
React\Promise\Timer\reject($time);
// new
React\Promise\Timer\sleep($time);
Feature: Support PHP 8.1 release.
(#50 by @Thomas-Gelf, #52 by @clue and #48 by @SimonFrings)
Improve API documentation and add parameter types and return types.
(#49 by @clue and #47 by @SimonFrings)
Feature: Support listening on existing file descriptors (FDs) with SocketServer
.
(#269 by @clue)
$socket = new React\Socket\SocketSever('php://fd/3');
This is particularly useful when using systemd socket activation like this:
$ systemd-socket-activate -l 8000 php examples/03-http-server.php php://fd/3
Feature: Improve error messages for failed connection attempts with errno
and errstr
.
(#265, #266, #267, #270 and #271 by @clue and #268 by @SimonFrings)
All error messages now always include the appropriate errno
and errstr
to
give more details about the error reason when available. Along with these
error details exposed by the underlying system functions, it will also
include the appropriate error constant name (such as ECONNREFUSED
) when
available. Accordingly, failed TCP/IP connections will now report the actual
underlying error condition instead of a generic "Connection refused" error.
Higher-level error messages will now consistently report the connection URI
scheme and hostname used in all error messages.
For most common use cases this means that simply reporting the Exception
message should give the most relevant details for any connection issues:
$connector = new React\Socket\Connector();
$connector->connect($uri)->then(function (React\Socket\ConnectionInterface $conn) {
// …
}, function (Exception $e) {
echo 'Error:' . $e->getMessage() . PHP_EOL;
});
Improve test suite, test against PHP 8.1 release.
(#274 by @SimonFrings)
Feature: Improve error reporting by appending previous exception messages.
(#26 by @clue)
For most common use cases this means that simply reporting the Exception
message should give the most relevant details for any issues:
React\Promise\Stream\buffer($stream)->then(function (string $contents) {
// …
}, function (Exception $e) {
echo 'Error:' . $e->getMessage() . PHP_EOL;
});
Improve documentation, describe promise and stream data types.
(#27 by @clue and #23 by @WyriHaximus)
Improve test suite and add .gitattributes
to exclude dev files from exports.
Use GitHub actions for continuous integration (CI) and run tests on PHPUnit 9 and PHP 8.
(#21 by @reedy and #22, #24 and #25 by @SimonFrings)
Feature / Fix: Skip sigchild check if phpinfo()
has been disabled.
(#89 by @clue)
Fix: Fix detecting closed socket pipes on PHP 8.
(#90 by @clue)
Feature: Update Browser
signature to take optional $connector
as first argument and
to match new Socket API without nullable loop arguments.
(#418 and #419 by @clue)
// unchanged
$browser = new React\Http\Browser();
// deprecated
$browser = new React\Http\Browser(null, $connector);
$browser = new React\Http\Browser($loop, $connector);
// new
$browser = new React\Http\Browser($connector);
$browser = new React\Http\Browser($connector, $loop);
Feature: Rename Server
to HttpServer
to avoid class name collisions and
to avoid any ambiguities with regards to the new SocketServer
API.
(#417 and #419 by @clue)
// deprecated
$server = new React\Http\Server($handler);
$server->listen(new React\Socket\Server(8080));
// new
$http = new React\Http\HttpServer($handler);
$http->listen(new React\Socket\SocketServer('127.0.0.1:8080'));
Feature: Add new SocketServer
and deprecate Server
to avoid class name collisions.
(#263 by @clue)
The new SocketServer
class has been added with an improved constructor signature
as a replacement for the previous Server
class in order to avoid any ambiguities.
The previous name has been deprecated and should not be used anymore.
In its most basic form, the deprecated Server
can now be considered an alias for new SocketServer
.
// deprecated
$socket = new React\Socket\Server(0);
$socket = new React\Socket\Server('127.0.0.1:8000');
$socket = new React\Socket\Server('127.0.0.1:8000', null, $context);
$socket = new React\Socket\Server('127.0.0.1:8000', $loop, $context);
// new
$socket = new React\Socket\SocketServer('127.0.0.1:0');
$socket = new React\Socket\SocketServer('127.0.0.1:8000');
$socket = new React\Socket\SocketServer('127.0.0.1:8000', $context);
$socket = new React\Socket\SocketServer('127.0.0.1:8000', $context, $loop);
Feature: Update Connector
signature to take optional $context
as first argument.
(#264 by @clue)
The new signature has been added to match the new SocketServer
and
consistently move the now commonly unneeded loop argument to the last argument.
The previous signature has been deprecated and should not be used anymore.
In its most basic form, both signatures are compatible.
// deprecated
$connector = new React\Socket\Connector(null, $context);
$connector = new React\Socket\Connector($loop, $context);
// new
$connector = new React\Socket\Connector($context);
$connector = new React\Socket\Connector($context, $loop);
A major new feature release, see release announcement.
Feature: Simplify usage by supporting new default loop.
(#46 by @clue)
// old (still supported)
$promise = timeout($promise, $time, $loop);
$promise = resolve($time, $loop);
$promise = reject($time, $loop);
// new (using default loop)
$promise = timeout($promise, $time);
$promise = resolve($time);
$promise = reject($time);
Improve test suite, use GitHub actions for continuous integration (CI),
update PHPUnit config, run tests on PHP 8 and add full core team to the license.
(#43 by @WyriHaximus, #44 and #45 by @SimonFrings)
A major new feature release, see release announcement.
Feature: Simplify usage by supporting new default loop.
(#42 by @clue)
// old (still supported)
$factory = new React\Datagram\Factory($loop);
// new (using default loop)
$factory = new React\Datagram\Factory();
A major new feature release, see release announcement.
Feature: Simplify usage by supporting new default loop.
(#87 by @clue)
// old (still supported)
$process = new React\ChildProcess\Process($command);
$process->start($loop);
// new (using default loop)
$process = new React\ChildProcess\Process($command);
$process->start();
A major new feature release, see release announcement.
Feature: Simplify usage by supporting new default loop.
(#410 by @clue)
// old (still supported)
$browser = new React\Http\Browser($loop);
$server = new React\Http\Server($loop, $handler);
// new (using default loop)
$browser = new React\Http\Browser();
$server = new React\Http\Server($handler);
A major new feature release, see release announcement.
Feature: Simplify usage by supporting new default loop.
(#260 by @clue)
// old (still supported)
$socket = new React\Socket\Server('127.0.0.1:8080', $loop);
$connector = new React\Socket\Connector($loop);
// new (using default loop)
$socket = new React\Socket\Server('127.0.0.1:8080');
$connector = new React\Socket\Connector();
A major new feature release, see release announcement.
Feature: Simplify usage by supporting new default loop.
(#182 by @clue)
// old (still supported)
$factory = new React\Dns\Resolver\Factory();
$resolver = $factory->create($config, $loop);
// new (using default loop)
$factory = new React\Dns\Resolver\Factory();
$resolver = $factory->create($config);
A major new feature release, see release announcement.
Feature: Simplify usage by supporting new default loop.
(#159 by @clue)
// old (still supported)
$stream = new ReadableResourceStream($resource, $loop);
$stream = new WritabeResourceStream($resource, $loop);
$stream = new DuplexResourceStream($resource, $loop);
// new (using default loop)
$stream = new ReadableResourceStream($resource);
$stream = new WritabeResourceStream($resource);
$stream = new DuplexResourceStream($resource);
Improve test suite, use GitHub actions for continuous integration (CI),
update PHPUnit config, run tests on PHP 8 and add full core team to the license.
(#153, #156 and #157 by @SimonFrings and #154 by @WyriHaximus)
A major new feature release, see release announcement.
Feature: Introduce new concept of default loop with the new Loop
class.
(#226 by @WyriHaximus, #229, #231 and #232 by @clue)
The Loop
class exists as a convenient global accessor for the event loop.
It provides all methods that exist on the LoopInterface
as static methods and
will automatically execute the loop at the end of the program:
$timer = Loop::addPeriodicTimer(0.1, function () {
echo 'Tick' . PHP_EOL;
});
Loop::addTimer(1.0, function () use ($timer) {
Loop::cancelTimer($timer);
echo 'Done' . PHP_EOL;
});
The explicit loop instructions are still valid and may still be useful in some applications,
especially for a transition period towards the more concise style.
The Loop::get()
method can be used to get the currently active event loop instance.
// deprecated
$loop = React\EventLoop\Factory::create();
// new
$loop = React\EventLoop\Loop::get();
Minor documentation improvements and mark legacy extensions as deprecated.
(#234 by @SimonFrings, #214 by @WyriHaximus and #233 and #235 by @nhedger)
Improve test suite, use GitHub actions for continuous integration (CI),
update PHPUnit config and run tests on PHP 8.
(#212 and #215 by @SimonFrings and #230 by @clue)
Feature: Support falling back to multiple DNS servers from DNS config.
(#41 by @clue)
When using the Factory
, it will now use all DNS servers configured on your
system. If you have multiple DNS servers configured and connectivity to the
primary DNS server is broken, it will now fall back to your other DNS
servers, thus providing improved connectivity and redundancy for broken DNS
configurations.
Feature: Support falling back to multiple DNS servers from DNS config.
(#257 by @clue)
If you're using the default Connector
, it will now use all DNS servers
configured on your system. If you have multiple DNS servers configured and
connectivity to the primary DNS server is broken, it will now fall back to
your other DNS servers, thus providing improved connectivity and redundancy
for broken DNS configurations.
Feature: Use round robin for happy eyeballs DNS responses (load balancing).
(#247 by @clue)
If you're using the default Connector
, it will now randomize the order of
the IP addresses resolved via DNS when connecting. This allows the load to
be distributed more evenly across all returned IP addresses. This can be
used as a very basic DNS load balancing mechanism.
Internal improvement to avoid unhandled rejection for future Promise API.
(#258 by @clue)
Improve test suite, use GitHub actions for continuous integration (CI).
(#254 by @SimonFrings)
Feature: Update DNS Factory
to accept complete Config
object.
Add new FallbackExecutor
and use fallback DNS servers when Config
lists multiple servers.
(#179 and #180 by @clue)
// old (still supported)
$config = React\Dns\Config\Config::loadSystemConfigBlocking();
$server = $config->nameservers ? reset($config->nameservers) : '8.8.8.8';
$resolver = $factory->create($server, $loop);
// new
$config = React\Dns\Config\Config::loadSystemConfigBlocking();
if (!$config->nameservers) {
$config->nameservers[] = '8.8.8.8';
}
$resolver = $factory->create($config, $loop);
Feature: Add support for legacy SPF
record type.
(#178 by @akondas and @clue)
Fix: Fix integer overflow for TCP/IP chunk size on 32 bit platforms.
(#177 by @clue)
Feature: Support persistent connections (Connection: keep-alive
).
(#405 by @clue)
This shows a noticeable performance improvement especially when benchmarking
using persistent connections (which is the default pretty much everywhere).
Together with other changes in this release, this improves benchmarking
performance by around 100%.
Feature: Require Host
request header for HTTP/1.1 requests.
(#404 by @clue)
Minor documentation improvements.
(#398 by @fritz-gerneth and #399 and #400 by @pavog)
Improve test suite, use GitHub actions for continuous integration (CI).
(#402 by @SimonFrings)
Fix: Minimal fix for PHP 8
(#154 by @remicollet)
Documentation: Add deprecation notice to suggest HTTP component instead
(#153 by @clue)
Feature: Improve error reporting when query fails, include domain and query type and DNS server address where applicable.
(#174 by @clue)
Feature: Improve error handling when sending data to DNS server fails (macOS).
(#171 and #172 by @clue)
Fix: Improve DNS response parser to limit recursion for compressed labels.
(#169 by @clue)
Improve test suite, use GitHub actions for continuous integration (CI).
(#170 by @SimonFrings)
Feature: Support PHP 8 (socket address of closed socket should be null).
(#39 by @clue)
Improve test suite and add .gitattributes
to exclude dev files from exports.
Run tests on PHPUnit 9, switch to GitHub actions and clean up test suite.
(#30, #31 and #38 by @clue, #34 by @reedy, #35 by @WyriHaximus and #37 by @SimonFrings)
Feature: Support PHP 8 and add non-blocking I/O support on Windows with PHP 8.
(#85 by @clue)
Minor documentation improvements.
(#78 by @WyriHaximus and #80 by @gdejong)
Improve test suite and add .gitattributes
to exclude dev files from exports.
Run tests on PHPUnit 9, switch to GitHub actions and clean up test suite.
(#75 by @reedy, #81 by @gdejong, #82 by @SimonFrings and #84 by @clue)
Feature: Keep request body in memory also after consuming request body.
(#395 by @clue)
This means consumers can now always access the complete request body as
detailed in the documentation. This allows building custom parsers and more
advanced processing models without having to mess with the default parsers.
Improve test suite and update to PHPUnit 9.3.
(#164 by @clue, #165 and #166 by @SimonFrings and #167 by @WyriHaximus)
Feature: Forward compatibility with react/promise 3.
(#39 by @WyriHaximus)
Add .gitattributes
to exclude dev files from exports.
(#40 by @reedy)
Improve test suite, update to support PHP 8 and PHPUnit 9.3.
(#41 and #43 by @SimonFrings and #42 by @WyriHaximus)
Feature: Support upcoming PHP 8 release, update to reactphp/socket v1.6 and adjust type checks for invalid chunk headers.
(#391 by @clue)
Feature: Consistently resolve base URL according to HTTP specs.
(#379 by @clue)
Feature / Fix: Expose Transfer-Encoding: chunked
response header and fix chunked responses for HEAD
requests.
(#381 by @clue)
Internal refactoring to remove unneeded MessageFactory
and Response
classes.
(#380 and #389 by @clue)
Minor documentation improvements and improve test suite, update to support PHPUnit 9.3.
(#385 by @clue and #393 by @SimonFrings)
Feature: Change default socket backlog size to 511.
(#242 by @clue)
Fix: Fix closing connection when cancelling during TLS handshake.
(#241 by @clue)
Fix: Fix blocking during possible accept()
race condition
when multiple socket servers listen on same socket address.
(#244 by @clue)
Improve test suite, update PHPUnit config and add full core team to the license.
(#243 by @SimonFrings and #245 by @WyriHaximus)
A major new feature release, see release announcement.
This update involves some major new features and a number of BC breaks due to
some necessary API cleanup. We've tried hard to avoid BC breaks where possible
and minimize impact otherwise. We expect that most consumers of this package
will be affected by BC breaks, but updating should take no longer than a few
minutes. See below for more details:
Feature: Add async HTTP client implementation.
(#368 by @clue)
$browser = new React\Http\Browser($loop);
$browser->get($url)->then(function (Psr\Http\Message\ResponseInterface $response) {
echo $response->getBody();
});
The code has been imported as-is from clue/reactphp-buzz v2.9.0,
with only minor changes to the namespace and we otherwise leave all the existing APIs unchanged.
Upgrading from clue/reactphp-buzz v2.9.0
to this release should be a matter of updating some namespace references only:
// old
$browser = new Clue\React\Buzz\Browser($loop);
// new
$browser = new React\Http\Browser($loop);
Feature / BC break: Add LoopInterface
as required first constructor argument to Server
and
change Server
to accept variadic middleware handlers instead of array
.
(#361 and #362 by @WyriHaximus)
// old
$server = new React\Http\Server($handler);
$server = new React\Http\Server([$middleware, $handler]);
// new
$server = new React\Http\Server($loop, $handler);
$server = new React\Http\Server($loop, $middleware, $handler);
Feature / BC break: Move Response
class to React\Http\Message\Response
and
expose ServerRequest
class to React\Http\Message\ServerRequest
.
(#370 by @clue)
// old
$response = new React\Http\Response(200, [], 'Hello!');
// new
$response = new React\Http\Message\Response(200, [], 'Hello!');
Feature / BC break: Add StreamingRequestMiddleware
to stream incoming requests, mark StreamingServer
as internal.
(#367 by @clue)
// old: advanced StreamingServer is now internal only
$server = new React\Http\StreamingServer($handler);
// new: use StreamingRequestMiddleware instead of StreamingServer
$server = new React\Http\Server(
$loop,
new React\Http\Middleware\StreamingRequestMiddleware(),
$handler
);
Feature / BC break: Improve default concurrency to 1024 requests and cap default request buffer at 64K.
(#371 by @clue)
This improves default concurrency to 1024 requests and caps the default request buffer at 64K.
The previous defaults resulted in just 4 concurrent requests with a request buffer of 8M.
See Server
for details on how to override these defaults.
Feature: Expose ReactPHP in User-Agent
client-side request header and in Server
server-side response header.
(#374 by @clue)
Mark all classes as final
to discourage inheriting from it.
(#373 by @WyriHaximus)
Improve documentation and use fully-qualified class names throughout the documentation and
add ReactPHP core team as authors to composer.json
and license file.
(#366 and #369 by @WyriHaximus and #375 by @clue)
Improve test suite and support skipping all online tests with --exclude-group internet
.
(#372 by @clue)
Feature: Forward compatibility with react/promise v3.
(#37 by @WyriHaximus)
Improve test suite and add .gitattributes
to exclude dev files from exports.
Run tests on PHPUnit 9 and PHP 7.4 and clean up test suite.
(#38 by @WyriHaximus, #39 by @reedy, #41 by @clue and #42 by @SimonFrings)
Feature: Forward compatibility with react/promise v3.
(#153 by @WyriHaximus)
Feature: Support parsing OPT
records (EDNS0).
(#157 by @clue)
Fix: Avoid PHP warnings due to lack of args in exception trace on PHP 7.4.
(#160 by @clue)
Improve test suite and add .gitattributes
to exclude dev files from exports.
Run tests on PHPUnit 9 and PHP 7.4 and clean up test suite.
(#154 by @reedy, #156 by @clue and #163 by @SimonFrings)
Fix: Fix parsing multipart request body with quoted header parameters (dot net).
(#363 by @ebimmel)
Fix: Fix calculating concurrency when post_max_size
ini is unlimited.
(#365 by @clue)
Improve test suite to run tests on PHPUnit 9 and clean up test suite.
(#364 by @SimonFrings)
Feature / Fix: Improve error handling and reporting for happy eyeballs and
immediately try next connection when one connection attempt fails.
(#230, #231, #232 and #233 by @clue)
Error messages for failed connection attempts now include more details to
ease debugging. Additionally, the happy eyeballs algorithm has been improved
to avoid having to wait for some timers to expire which significantly
improves connection setup times (in particular when IPv6 isn't available).
Improve test suite, minor code cleanup and improve code coverage to 100%.
Update to PHPUnit 9 and skip legacy TLS 1.0 / TLS 1.1 tests if disabled by
system. Run tests on Windows and simplify Travis CI test matrix for Mac OS X
setup and skip all TLS tests on legacy HHVM.
(#229, #235, #236 and #238 by @clue and #239 by @SimonFrings)
Mark FulfilledPromise
, RejectedPromise
and LazyPromise
as deprecated for Promise v2 (and remove for Promise v3).
(#143 and #165 by @clue)
// deprecated
$fulfilled = new React\Promise\FulfilledPromise($value);
$rejected = new React\Promise\RejectedPromise($reason);
// recommended alternatives
$fulfilled = React\Promise\resolve($value);
$rejected = React\Promise\reject($reason);
Fix: Fix checking whether cancellable promise is an object and avoid possible warning.
(#168 by @smscr and @jsor)
Improve documentation and add docblocks to functions and interfaces.
(#135 by @CharlotteDunois)
Add .gitattributes
to exclude dev files from exports.
(#154 by @reedy)
Improve test suite, run tests on PHP 7.4 and update PHPUnit test setup.
(#163 by @clue)
Fix: Fix faulty write buffer behavior when sending large data chunks over TLS (Mac OS X only).
(#150 by @clue)
Minor code style improvements to fix phpstan analysis warnings and
add .gitattributes
to exclude dev files from exports.
(#140 by @flow-control and #144 by @reedy)
Improve test suite to run tests on PHP 7.4 and simplify test matrix.
(#147 by @clue)
A major new feature release, see release announcement.
Feature: Add IPv6 support to Connector
(implement "Happy Eyeballs" algorithm to support IPv6 probing).
IPv6 support is turned on by default, use new happy_eyeballs
option in Connector
to toggle behavior.
(#196, #224 and #225 by @WyriHaximus and @clue)
Feature: Default to using DNS cache (with max 256 entries) for Connector
.
(#226 by @clue)
Add .gitattributes
to exclude dev files from exports and some minor code style fixes.
(#219 by @reedy and #218 by @mmoreram)
Improve test suite to fix failing test cases when using new DNS component,
significantly improve test performance by awaiting events instead of sleeping,
exclude TLS 1.3 test on PHP 7.3, run tests on PHP 7.4 and simplify test matrix.
(#208, #209, #210, #217 and #223 by @clue)
Fix: Avoid unneeded warning when decoding invalid data on PHP 7.4.
(#150 by @clue)
Add .gitattributes
to exclude dev files from exports.
(#149 by @reedy)
Link to clue/reactphp-buzz for higher-level HTTP client.
(#139 by @clue)
Improve test suite by simplifying test matrix and test setup.
(#151 by @clue)
Fix: Fix parsing Cookie
request header with comma in its values.
(#352 by @Fiskie)
Fix: Avoid unneeded warning when decoding invalid data on PHP 7.4.
(#357 by @WyriHaximus)
Add .gitattributes to exclude dev files from exports.
(#353 by @reedy)
Fix: Fix reporting connection refused errors with ExtUvLoop
on Linux and StreamSelectLoop
on Windows.
(#207 and #208 by @clue)
Fix: Fix unsupported EventConfig and SEGFAULT
on shutdown with ExtEventLoop
on Windows.
(#205 by @clue)
Fix: Prevent interval overflow for timers very far in the future with ExtUvLoop
.
(#196 by @PabloKowalczyk)
Fix: Check PCNTL functions for signal support instead of PCNTL extension with StreamSelectLoop
.
(#195 by @clue)
Add .gitattributes
to exclude dev files from exports.
(#201 by @reedy)
Improve test suite to fix testing ExtUvLoop
on Travis,
fix Travis CI builds, do not install libuv
on legacy PHP setups,
fix failing test cases due to inaccurate timers,
run tests on Windows via Travis CI and
run tests on PHP 7.4 and simplify test matrix and test setup.
(#197 by @WyriHaximus and #202, #203, #204 and #209 by @clue)
Internal refactorings and optimizations to improve request parsing performance.
Benchmarks suggest number of requests/s improved by ~30% for common GET
requests.
(#345, #346, #349 and #350 by @clue)
Add documentation and example for JSON/XML request body and
improve documentation for concurrency and streaming requests and for error handling.
(#341 and #342 by @clue)
Feature: Add TcpTransportExecutor
to send DNS queries over TCP/IP connection,
add SelectiveTransportExecutor
to retry with TCP if UDP is truncated and
automatically select transport protocol when no explicit udp://
or tcp://
scheme is given in Factory
.
(#145, #146, #147 and #148 by @clue)
Feature: Support escaping literal dots and special characters in domain names.
(#144 by @clue)
Feature: Support parsing CAA
and SSHFP
records.
(#141 and #142 by @clue)
Feature: Add ResolverInterface
as common interface for Resolver
class.
(#139 by @clue)
Fix: Add missing private property definitions and
remove unneeded dependency on react/stream
.
(#140 and #143 by @clue)
This update involves a number of BC breaks due to dropped support for
deprecated functionality and some internal API cleanup. We've tried hard to
avoid BC breaks where possible and minimize impact otherwise. We expect that
most consumers of this package will actually not be affected by any BC
breaks, see below for more details:
BC break: Delete all deprecated APIs, use Query
objects for Message
questions
instead of nested arrays and increase code coverage to 100%.
(#130 by @clue)
BC break: Move $nameserver
from ExecutorInterface
to UdpTransportExecutor
,
remove advanced/internal UdpTransportExecutor
args for Parser
/BinaryDumper
and
add API documentation for ExecutorInterface
.
(#135, #137 and #138 by @clue)
BC break: Replace HeaderBag
attributes with simple Message
properties.
(#132 by @clue)
BC break: Mark all Record
attributes as required, add documentation vs Query
.
(#136 by @clue)
BC break: Mark all classes as final to discourage inheritance
(#134 by @WyriHaximus)
Contains no other changes, so it's actually fully compatible with the v0.6.0 release.
Feature: Forward compatibility with upcoming stable DNS component.
(#29 by @clue)
Prefix all global functions calls with \
to skip the look up and resolve process and go straight to the global function.
(#28 by @WyriHaximus)
Improve test suite to also test against PHP 7.1 and 7.2.
(#25 by @andreybolonin)
Feature / Fix: Implement CachingExecutor
using cache TTL, deprecate old CachedExecutor
,
respect TTL from response records when caching and do not cache truncated responses.
(#129 by @clue)
Feature: Limit cache size to 256 last responses by default.
(#127 by @clue)
Feature: Cooperatively resolve hosts to avoid running same query concurrently.
(#125 by @clue)
Feature / BC break: Add support for getMultiple()
, setMultiple()
, deleteMultiple()
, clear()
and has()
supporting multiple cache items (inspired by PSR-16).
(#32 by @krlv and #37 by @clue)
Documentation for TTL precision with millisecond accuracy or below and
use high-resolution timer for cache TTL on PHP 7.3+.
(#35 and #38 by @clue)
Improve API documentation and allow legacy HHVM to fail in Travis CI config.
(#34 and #36 by @clue)
Prefix all global functions calls with \ to skip the look up and resolve process and go straight to the global function.
(#31 by @WyriHaximus)
Feature: Support unwrapping object streams by buffering original write chunks in array.
(#15 by @clue)
Feature: Clean up unneeded references for unwrapped streams when closing.
(#18 by @clue)
Fix: Writing to closed unwrapped stream should return false (backpressure).
(#17 by @clue)
Improve test suite to support PHPUnit 7, PHP 7.3 and fix incomplete test
and improve API documentation.
(#16 and #19 by @clue)
Avoid uneeded fragmented TLS work around for PHP 7.3.3+ and
work around failing test case detecting EOF on TLS 1.3 socket streams.
(#201 and #202 by @clue)
Feature: Support parsing authority
and additional
records from DNS response.
(#123 by @clue)
Feature: Support dumping records as part of outgoing binary DNS message.
(#124 by @clue)
Feature: Forward compatibility with upcoming Cache v0.6 and Cache v1.0
(#121 by @clue)
Improve test suite to add forward compatibility with PHPUnit 7,
test against PHP 7.3 and use legacy PHPUnit 5 on legacy HHVM.
(#122 by @clue)
New UV based event loop (ext-uv).
(#112 by @WyriHaximus)
Improve PCNTL signals by using async signal dispatching if available.
(#179 by @CharlotteDunois)
Improve test suite and test suite set up.
(#174 by @WyriHaximus, #181 by @clue)
Improvement: Internal refactoring to simplify response header logic.
(#321 by @clue)
Improvement: Assign Content-Length response header automatically only when size is known.
(#329 by @clue)
Improvement: Import global functions for better performance.
(#330 by @WyriHaximus)
A major feature release with some minor API improvements!
This project now has limited Windows support and supports passing custom pipes
and file descriptors to the child process.
This update involves a few minor BC breaks. We've tried hard to avoid BC breaks
where possible and minimize impact otherwise. We expect that most consumers of
this package will actually not be affected by any BC breaks, see below for more
details.
Feature / BC break: Support passing custom pipes and file descriptors to child process,
expose all standard I/O pipes in an array and remove unused Windows-only options.
(#62, #64 and #65 by @clue)
BC note: The optional
$options
parameter in theProcess
constructor
has been removed and a new$fds
parameter has been added instead. The
previous$options
parameter was Windows-only, available options were not
documented or referenced anywhere else in this library, so its actual
impact is expected to be relatively small. See the documentation and the
following changelog entry if you're looking for Windows support.
Feature: Support spawning child process on Windows without process I/O pipes.
(#67 by @clue)
Feature / BC break: Improve sigchild compatibility and support explicit configuration.
(#63 by @clue)
// advanced: not recommended by default
Process::setSigchildEnabled(true);
BC note: The old public sigchild methods have been removed, but its
practical impact is believed to be relatively small due to the automatic detection.
Improve performance by prefixing all global functions calls with \ to skip
the look up and resolve process and go straight to the global function.
(#68 by @WyriHaximus)
Minor documentation improvements and docblock updates.
(#59 by @iamluc and #69 by @CharlotteDunois)
Improve test suite to test against PHP7.2 and PHP 7.3, improve HHVM compatibility,
add forward compatibility with PHPUnit 7 and run tests on Windows via Travis CI.
(#66 and #71 by @clue)
Feature / Fix: Improve TLS 1.3 support.
(#186 by @clue)
TLS 1.3 is now an official standard as of August 2018! 🎉
The protocol has major improvements in the areas of security, performance, and privacy.
TLS 1.3 is supported by default as of OpenSSL 1.1.1.
For example, this version ships with Ubuntu 18.10 (and newer) by default, meaning that recent installations support TLS 1.3 out of the box
Fix: Avoid possibility of missing remote address when TLS handshake fails.
(#188 by @clue)
Improve performance by prefixing all global functions calls with \
to skip the look up and resolve process and go straight to the global function.
(#183 by @WyriHaximus)
Update documentation to use full class names with namespaces.
(#187 by @clue)
Improve test suite to avoid some possible race conditions,
test against PHP 7.3 on Travis and
use dedicated assertInstanceOf()
assertions.
(#185 by @clue, #178 by @WyriHaximus and #181 by @carusogabriel)
Improvement: Increase performance by optimizing global function and constant look ups.
(#137 by @WyriHaximus)
Travis: Test against PHP 7.3.
(#138 by @WyriHaximus)
Fix: Ignore empty reads.
(#139 by @WyriHaximus)
Feature: Improve promise cancellation for DNS lookup retries and clean up any garbage references.
(#118 by @clue)
Fix: Reject parsing malformed DNS response messages such as incomplete DNS response messages,
malformed record data or malformed compressed domain name labels.
(#115 and #117 by @clue)
Fix: Fix interpretation of TTL as UINT32 with most significant bit unset.
(#116 by @clue)
Fix: Fix caching advanced MX/SRV/TXT/SOA structures.
(#112 by @clue)
Feature: Improve error reporting for failed connection attempts and improve
cancellation forwarding during DNS lookup, TCP/IP connection or TLS handshake.
(#168, #169, #170, #171, #176 and #177 by @clue)
All error messages now always contain a reference to the remote URI to give
more details which connection actually failed and the reason for this error.
Accordingly, failures during DNS lookup will now mention both the remote URI
as well as the DNS error reason. TCP/IP connection issues and errors during
a secure TLS handshake will both mention the remote URI as well as the
underlying socket error. Similarly, lost/dropped connections during a TLS
handshake will now report a lost connection instead of an empty error reason.
For most common use cases this means that simply reporting the Exception
message should give the most relevant details for any connection issues:
$promise = $connector->connect('tls://example.com:443');
$promise->then(function (ConnectionInterface $conn) use ($loop) {
// …
}, function (Exception $e) {
echo $e->getMessage();
});
Contains no other changes, so it's actually fully compatible with the v0.8.12 release.
Contains no other changes, so it's actually fully compatible with the v0.7.7 release.
Contains no other changes, so it's actually fully compatible with the v0.5.3 release.
Improve performance by importing global functions.
(#167 by @Ocramius)
Improve test suite by simplifying test bootstrap by using dev autoloader.
(#169 by @lcobucci)
Minor internal changes to improved backward compatibility with PHP 5.3.
(#166 by @Donatello-za)
Feature: Add resolveAll()
method to support custom query types in Resolver
.
(#110 by @clue and @WyriHaximus)
$resolver->resolveAll('reactphp.org', Message::TYPE_AAAA)->then(function ($ips) {
echo 'IPv6 addresses for reactphp.org ' . implode(', ', $ips) . PHP_EOL;
});
Feature: Support parsing NS
, TXT
, MX
, SOA
and SRV
records.
(#104, #105, #106, #107 and #108 by @clue)
Feature: Add support for Message::TYPE_ANY
and parse unknown types as binary data.
(#104 by @clue)
Feature: Improve error messages for failed queries and improve documentation.
(#109 by @clue)
Feature: Add UdpTransportExecutor
, validate incoming DNS response messages
to avoid cache poisoning attacks and deprecate legacy Executor
.
(#101 and #103 by @clue)
Feature: Forward compatibility with Cache 0.5
(#102 by @clue)
Deprecate legacy Query::$currentTime
and binary parser data attributes to clean up and simplify API.
(#99 by @clue)
Improve documentation by describing what is expected of a class implementing CacheInterface
.
(#21, #22, #23, #27 by @WyriHaximus)
Implemented (optional) Least Recently Used (LRU) cache algorithm for ArrayCache
.
(#26 by @clue)
Added support for cache expiration (TTL).
(#29 by @clue and @WyriHaximus)
Renamed remove
to delete
making it more in line with PSR-16
.
(#30 by @clue)
Feature: Improve memory consumption for failed and cancelled connection attempts.
(#161 by @clue)
Improve test suite to fix Travis config to test against legacy PHP 5.3 again.
(#162 by @clue)
Feature: Significantly improve memory consumption and performance by only passing resolver args
to resolver and canceller if callback requires them. Also use static callbacks without
binding to promise, clean up canceller function reference when they are no longer
needed and hide resolver and canceller references from call stack on PHP 7+.
(#113, #115, #116, #117, #118, #119 and #123 by @clue)
These changes combined mean that rejecting promises with an Exception
should
no longer cause any internal circular references which could cause some unexpected
memory growth in previous versions. By explicitly avoiding and explicitly
cleaning up said references, we can avoid relying on PHP's circular garbage collector
to kick in which significantly improves performance when rejecting many promises.
Mark legacy progress support / notification API as deprecated
(#112 by @clue)
Recommend rejecting promises by throwing an exception
(#114 by @jsor)
Improve documentation to properly instantiate LazyPromise
(#121 by @holtkamp)
Follower cancellation propagation was originally planned for this release
but has been reverted for now and is planned for a future release.
(#99 by @jsor and #122 by @clue)
Feature: Improve memory consumption and runtime performance for StreamSelectLoop
timers.
(#164 by @clue)
Improve test suite by removing I/O dependency at StreamSelectLoopTest
to fix Mac OS X tests.
(#161 by @nawarian)
Feature: Do not pause connection stream to detect closed connections immediately.
(#315 by @clue)
Feature: Keep incoming Transfer-Encoding: chunked
request header.
(#316 by @clue)
Feature: Reject invalid requests that contain both Content-Length
and Transfer-Encoding
request headers.
(#318 by @clue)
Minor internal refactoring to simplify connection close logic after sending response.
(#317 by @clue)
Feature: Support legacy HTTP servers that use only LF
instead of CRLF
.
(#130 by @clue)
Improve test suite by applying maximum test timeouts for integration tests.
(#131 by @clue)
ExtEvLoop
(PECL ext-ev) (#148 by @kaduev13)Fix: Do not pass $next
handler to final request handler.
(#308 by @clue)
Fix: Fix awaiting queued handlers when cancelling a queued handler.
(#313 by @clue)
Fix: Fix Server to skip SERVER_ADDR
params for Unix domain sockets (UDS).
(#307 by @clue)
Documentation for PSR-15 middleware and minor documentation improvements.
(#314 by @clue and #297, #298 and #310 by @seregazhuk)
Minor code improvements and micro optimizations.
(#301 by @seregazhuk and #305 by @kalessil)
A major feature release with a significant documentation overhaul and long overdue API cleanup!
This update involves a number of BC breaks due to dropped support for deprecated
functionality. We've tried hard to avoid BC breaks where possible and minimize
impact otherwise. We expect that most consumers of this package will actually
not be affected by any BC breaks, see below for more details.
We realize that the changes listed below may seem overwhelming, but we've tried
to be very clear about any possible BC breaks. Don't worry: In fact, all ReactPHP
components are already compatible and support both this new release as well as
providing backwards compatibility with the last release.
Feature / BC break: Add support for signal handling via new
LoopInterface::addSignal()
and LoopInterface::removeSignal()
methods.
(#104 by @WyriHaximus and #111 and #150 by @clue)
$loop->addSignal(SIGINT, function () {
echo 'CTRL-C';
});
Feature: Significant documentation updates for LoopInterface
and Factory
.
(#100, #119, #126, #127, #159 and #160 by @clue, #113 by @WyriHaximus and #81 and #91 by @jsor)
Feature: Add examples to ease getting started
(#99, #100 and #125 by @clue, #59 by @WyriHaximus and #143 by @jsor)
Feature: Documentation for advanced timer concepts, such as monotonic time source vs wall-clock time
and high precision timers with millisecond accuracy or below.
(#130 and #157 by @clue)
Feature: Documentation for advanced stream concepts, such as edge-triggered event listeners
and stream buffers and allow throwing Exception if stream resource is not supported.
(#129 and #158 by @clue)
Feature: Throw BadMethodCallException
on manual loop creation when required extension isn't installed.
(#153 by @WyriHaximus)
Feature / BC break: First class support for legacy PHP 5.3 through PHP 7.2 and HHVM
and remove all callable
type hints for consistency reasons.
(#141 and #151 by @clue)
BC break: Documentation for timer API and clean up unneeded timer API.
(#102 by @clue)
Remove TimerInterface::cancel()
, use LoopInterface::cancelTimer()
instead:
// old (method invoked on timer instance)
$timer->cancel();
// already supported before: invoke method on loop instance
$loop->cancelTimer($timer);
Remove unneeded TimerInterface::setData()
and TimerInterface::getData()
,
use closure binding to add arbitrary data to timer instead:
// old (limited setData() and getData() only allows single variable)
$name = 'Tester';
$timer = $loop->addTimer(1.0, function ($timer) {
echo 'Hello ' . $timer->getData() . PHP_EOL;
});
$timer->setData($name);
// already supported before: closure binding allows any number of variables
$name = 'Tester';
$loop->addTimer(1.0, function () use ($name) {
echo 'Hello ' . $name . PHP_EOL;
});
Remove unneeded TimerInterface::getLoop()
, use closure binding instead:
// old (getLoop() called on timer instance)
$loop->addTimer(0.1, function ($timer) {
$timer->getLoop()->stop();
});
// already supported before: use closure binding as usual
$loop->addTimer(0.1, function () use ($loop) {
$loop->stop();
});
BC break: Remove unneeded LoopInterface::isTimerActive()
and
TimerInterface::isActive()
to reduce API surface.
(#133 by @clue)
// old (method on timer instance or on loop instance)
$timer->isActive();
$loop->isTimerActive($timer);
BC break: Move TimerInterface
one level up to React\EventLoop\TimerInterface
.
(#138 by @WyriHaximus)
// old (notice obsolete "Timer" namespace)
assert($timer instanceof React\EventLoop\Timer\TimerInterface);
// new
assert($timer instanceof React\EventLoop\TimerInterface);
BC break: Remove unneeded LoopInterface::nextTick()
(and internal NextTickQueue
),
use LoopInterface::futureTick()
instead.
(#30 by @clue)
// old (removed)
$loop->nextTick(function () {
echo 'tick';
});
// already supported before
$loop->futureTick(function () {
echo 'tick';
});
BC break: Remove unneeded $loop
argument for LoopInterface::futureTick()
(and fix internal cyclic dependency).
(#103 by @clue)
// old ($loop gets passed by default)
$loop->futureTick(function ($loop) {
$loop->stop();
});
// already supported before: use closure binding as usual
$loop->futureTick(function () use ($loop) {
$loop->stop();
});
BC break: Remove unneeded LoopInterface::tick()
.
(#72 by @jsor)
// old (removed)
$loop->tick();
// suggested work around for testing purposes only
$loop->futureTick(function () use ($loop) {
$loop->stop();
});
BC break: Documentation for advanced stream API and clean up unneeded stream API.
(#110 by @clue)
Remove unneeded $loop
argument for LoopInterface::addReadStream()
and LoopInterface::addWriteStream()
, use closure binding instead:
// old ($loop gets passed by default)
$loop->addReadStream($stream, function ($stream, $loop) {
$loop->removeReadStream($stream);
});
// already supported before: use closure binding as usual
$loop->addReadStream($stream, function ($stream) use ($loop) {
$loop->removeReadStream($stream);
});
BC break: Remove unneeded LoopInterface::removeStream()
method,
use LoopInterface::removeReadStream()
and LoopInterface::removeWriteStream()
instead.
(#118 by @clue)
// old
$loop->removeStream($stream);
// already supported before
$loop->removeReadStream($stream);
$loop->removeWriteStream($stream);
BC break: Rename LibEventLoop
to ExtLibeventLoop
and LibEvLoop
to ExtLibevLoop
for consistent naming for event loop implementations.
(#128 by @clue)
BC break: Remove optional EventBaseConfig
argument from ExtEventLoop
and make its FEATURE_FDS
enabled by default.
(#156 by @WyriHaximus)
BC break: Mark all classes as final to discourage inheritance.
(#131 by @clue)
Fix: Fix ExtEventLoop
to keep track of stream resources (refcount)
(#123 by @clue)
Fix: Ensure large timer interval does not overflow on 32bit systems
(#132 by @clue)
Fix: Fix separately removing readable and writable side of stream when closing
(#139 by @clue)
Fix: Properly clean up event watchers for ext-event
and ext-libev
(#149 by @clue)
Fix: Minor code cleanup and remove unneeded references
(#145 by @seregazhuk)
Fix: Discourage outdated ext-libevent
on PHP 7
(#62 by @cboden)
Improve test suite by adding forward compatibility with PHPUnit 6 and PHPUnit 5,
lock Travis distro so new defaults will not break the build,
improve test suite to be less fragile and increase test timeouts,
test against PHP 7.2 and reduce fwrite() call length to one chunk.
(#106 and #144 by @clue, #120 and #124 by @carusogabriel, #147 by nawarian and #92 by @kelunik)
A number of changes were originally planned for this release but have been backported
to the last v0.4.3
already: #74, #76, #79, #81 (refs #65, #66, #67), #88 and #93
Feature: Update DNS dependency to support loading system default DNS
nameserver config on all supported platforms
(/etc/resolv.conf
on Unix/Linux/Mac/Docker/WSL and WMIC on Windows)
(#23 by @clue)
This means that connecting to hosts that are managed by a local DNS server,
such as a corporate DNS server or when using Docker containers, will now
work as expected across all platforms with no changes required:
$factory = new Factory($loop);
$factory->createClient('intranet.example:5353');
Feature: Update DNS dependency to support loading system default DNS
nameserver config on all supported platforms
(/etc/resolv.conf
on Unix/Linux/Mac/Docker/WSL and WMIC on Windows)
(#152 by @clue)
This means that connecting to hosts that are managed by a local DNS server,
such as a corporate DNS server or when using Docker containers, will now
work as expected across all platforms with no changes required:
$connector = new Connector($loop);
$connector->connect('intranet.example:80')->then(function ($connection) {
// …
});
Add Config::loadSystemConfigBlocking()
to load default system config
and support parsing DNS config on all supported platforms
(/etc/resolv.conf
on Unix/Linux/Mac and WMIC on Windows)
(#92, #93, #94 and #95 by @clue)
$config = Config::loadSystemConfigBlocking();
$server = $config->nameservers ? reset($config->nameservers) : '8.8.8.8';
Remove unneeded cyclic dependency on react/socket
(#96 by @clue)
Support legacy PHP 5.3 through PHP 7.2 and HHVM
(#126 and #127 by @clue)
Improve backwards compatibility with Promise v1 and
use RingCentral to improve interoperability with react/http.
(#124 and #125 by @clue)
Fix: Ignore excessive whitespace in chunk header for Transfer-Encoding: chunked
(#123 by @DangerLifter and @clue)
Fix: Ignore invalid incoming Transfer-Encoding
response header
(#122 by @clue)
Improve documentation for Client
(and advanced Connector
)
(#111 by @jsor and #121 by @clue)
Improve test suite by adding support for PHPUnit 6
(#112 by @carusogabriel)
Feature: Detect "exit" immediately if last process pipe is closed
(#58 by @clue)
This introduces a simple check to see if the program is already known to be
closed when the last process pipe is closed instead of relying on a periodic
timer. This simple change improves "exit" detection significantly for most
programs and does not cause a noticeable penalty for more advanced use cases.
Fix forward compatibility with upcoming EventLoop releases
(#56 by @clue)
Feature: Support explicitly choosing TLS version to negotiate with remote side
by respecting crypto_method
context parameter for all classes.
(#149 by @clue)
By default, all connector and server classes support TLSv1.0+ and exclude
support for legacy SSLv2/SSLv3. As of PHP 5.6+ you can also explicitly
choose the TLS version you want to negotiate with the remote side:
// new: now supports 'crypto_method` context parameter for all classes
$connector = new Connector($loop, array(
'tls' => array(
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
)
));
Minor internal clean up to unify class imports
(#148 by @clue)
Major request handler performance improvement. Benchmarks suggest number of
requests/s improved by more than 50% for common GET
requests!
We now avoid queuing, buffering and wrapping incoming requests in promises
when we're below limits and instead can directly process common requests.
(#291, #292, #293, #294 and #296 by @clue)
Fix: Fix concurrent invoking next middleware request handlers
(#293 by @clue)
Small code improvements
(#286 by @seregazhuk)
Improve test suite to be less fragile when using ext-event
and
fix test suite forward compatibility with upcoming EventLoop releases
(#288 and #290 by @clue)
Fix: Fix closing socket resource before removing from loop
(#141 by @clue)
This fixes the root cause of an uncaught Exception
that only manifested
itself after the recent Stream v0.7.4 component update and only if you're
using ext-event
(ExtEventLoop
).
Improve test suite by testing against PHP 7.2
(#140 by @carusogabriel)
Improve test suite by adding forward compatiblity with PHPUnit 6 and
fix test suite forward compatibility with upcoming EventLoop releases
(#30 and #31 by @clue)
Fix: Fix all()
to assume null values if no event data is passed
(#13 by @clue)
Improve test suite by simplifying test bootstrapping logic via Composer and
add forward compatibility with PHPUnit 5 and PHPUnit 6 and
test against PHP 7.1 and 7.2
(#11 and #12 by @clue and #9 by @carusogabriel)
Fix: Update Stream dependency to work around SEGFAULT in legacy PHP < 5.4.28
and PHP < 5.5.12
(#50 and #52 by @clue)
Improve test suite by simplifying test bootstrapping logic via Composer and
adding forward compatibility with PHPUnit 6
(#53, #54 and #55 by @clue)
Fix: Work around reading from unbuffered pipe stream in legacy PHP < 5.4.28 and PHP < 5.5.12
(#126 by @clue)
Improve test suite by simplifying test bootstrapping logic via Composer and
test against PHP 7.2
(#127 by @clue and #124 by @carusogabriel)
Improve documentation with usage and installation instructions
(#10 by @clue)
Improve test suite by adding PHPUnit to require-dev
and
add forward compatibility with PHPUnit 5 and PHPUnit 6 and
sanitize Composer autoload paths
(#14 by @shaunbramley and #12 and #18 by @clue)
Feature / BC break: Add new Server
facade that buffers and parses incoming
HTTP requests. This provides full PSR-7 compatibility, including support for
form submissions with POST fields and file uploads.
The old Server
has been renamed to StreamingServer
for advanced usage
and is used internally.
(#266, #271, #281, #282, #283 and #284 by @WyriHaximus and @clue)
// old: handle incomplete/streaming requests
$server = new Server($handler);
// new: handle complete, buffered and parsed requests
// new: full PSR-7 support, including POST fields and file uploads
$server = new Server($handler);
// new: handle incomplete/streaming requests
$server = new StreamingServer($handler);
While this is technically a small BC break, this should in fact not break
most consuming code. If you rely on the old request streaming, you can
explicitly use the advancedStreamingServer
to restore old behavior.
Feature: Add support for middleware request handler arrays
(#215, #228, #229, #236, #237, #238, #246, #247, #277, #279 and #285 by @WyriHaximus, @clue and @jsor)
// new: middleware request handler arrays
$server = new Server(array(
function (ServerRequestInterface $request, callable $next) {
$request = $request->withHeader('Processed', time());
return $next($request);
},
function (ServerRequestInterface $request) {
return new Response();
}
));
Feature: Add support for limiting how many next request handlers can be
executed concurrently (LimitConcurrentRequestsMiddleware
)
(#272 by @clue and @WyriHaximus)
// new: explicitly limit concurrency
$server = new Server(array(
new LimitConcurrentRequestsMiddleware(10),
$handler
));
Feature: Add support for buffering the incoming request body
(RequestBodyBufferMiddleware
).
This feature mimics PHP's default behavior and respects its post_max_size
ini setting by default and allows explicit configuration.
(#216, #224, #263, #276 and #278 by @WyriHaximus and #235 by @andig)
// new: buffer up to 10 requests with 8 MiB each
$server = new StreamingServer(array(
new LimitConcurrentRequestsMiddleware(10),
new RequestBodyBufferMiddleware('8M'),
$handler
));
Feature: Add support for parsing form submissions with POST fields and file
uploads (RequestBodyParserMiddleware
).
This feature mimics PHP's default behavior and respects its ini settings and
MAX_FILE_SIZE
POST fields by default and allows explicit configuration.
(#220, #226, #252, #261, #264, #265, #267, #268, #274 by @WyriHaximus and @clue)
// new: buffer up to 10 requests with 8 MiB each
// and limit to 4 uploads with 2 MiB each
$server = new StreamingServer(array(
new LimitConcurrentRequestsMiddleware(10),
new RequestBodyBufferMiddleware('8M'),
new RequestBodyParserMiddleware('2M', 4)
$handler
));
Feature: Update Socket to work around sending secure HTTPS responses with PHP < 7.1.4
(#244 by @clue)
Feature: Support sending same response header multiple times (e.g. Set-Cookie
)
(#248 by @clue)
Feature: Raise maximum request header size to 8k to match common implementations
(#253 by @clue)
Improve test suite by adding forward compatibility with PHPUnit 6, test
against PHP 7.1 and PHP 7.2 and refactor and remove risky and duplicate tests.
(#243, #269 and #270 by @carusogabriel and #249 by @clue)
Minor code refactoring to move internal classes to React\Http\Io
namespace
and clean up minor code and documentation issues
(#251 by @clue, #227 by @kalessil, #240 by @christoph-kluge, #230 by @jsor and #280 by @andig)
Feature: Reject first()
when stream emits an error event
(#7 by @clue)
Fix: Explicit close()
of unwrapped stream should not emit error
event
(#8 by @clue)
Internal refactoring to simplify buffer()
function
(#6 by @kelunik)
Fix: Igore excessive fopen()
mode flags for WritableResourceStream
(#119 by @clue)
Fix: Fix forward compatibility with upcoming EventLoop releases
(#121 by @clue)
Restructure examples to ease getting started
(#123 by @clue)
Improve test suite by adding forward compatibility with PHPUnit 6 and
ignore Mac OS X test failures for now until Travis tests work again
(#122 by @Gabriel-Caruso and #120 by @clue)
Feature: Add Unix domain socket (UDS) support to Server
with unix://
URI scheme
and add advanced UnixServer
class.
(#120 by @andig)
// new: Server now supports "unix://" scheme
$server = new Server('unix:///tmp/server.sock', $loop);
// new: advanced usage
$server = new UnixServer('/tmp/server.sock', $loop);
Restructure examples to ease getting started
(#136 by @clue)
Improve test suite by adding forward compatibility with PHPUnit 6 and
ignore Mac OS X test failures for now until Travis tests work again
(#133 by @Gabriel-Caruso and #134 by @clue)
Contains no other changes, so it's actually fully compatible with the v0.1.2 release.
Fix: Work around PHP bug with Unix domain socket (UDS) paths for Mac OS X
(#123 by @andig)
Fix: Fix SecureServer
to return null
URI if server socket is already closed
(#129 by @clue)
Improve test suite by adding forward compatibility with PHPUnit v5 and
forward compatibility with upcoming EventLoop releases in tests and
test Mac OS X on Travis
(#122 by @andig and #125, #127 and #130 by @clue)
buffer()
(#3 by @WyriHaximus)Fix: Remove event listeners from CompositeStream
once closed and
remove undocumented left-over close
event argument
(#116 by @clue)
Minor documentation improvements: Fix wrong class name in example,
fix typos in README and
fix forward compatibility with upcoming EventLoop releases in example
(#113 by @docteurklein and #114 and #115 by @clue)
Improve test suite by running against Mac OS X on Travis
(#112 by @clue)
Feature: Always use Resolver
with default DNS to match Socket component
and update DNS dependency to support hosts file on all platforms
(#19 and #20 by @clue)
This means that connecting to hosts such as localhost
(and for example
those used for Docker containers) will now work as expected across all
platforms with no changes required:
$factory = new Factory($loop);
$factory->createClient('localhost:5353');
Feature: Add FixedUriConnector
decorator to use fixed, preconfigured URI instead
(#117 by @clue)
This can be useful for consumers that do not support certain URIs, such as
when you want to explicitly connect to a Unix domain socket (UDS) path
instead of connecting to a default address assumed by an higher-level API:
$connector = new FixedUriConnector(
'unix:///var/run/docker.sock',
new UnixConnector($loop)
);
// destination will be ignored, actually connects to Unix domain socket
$promise = $connector->connect('localhost:80');
Feature: Reduce memory consumption for failed connections
(#113 by @valga)
Fix: Work around write chunk size for TLS streams for PHP < 7.1.14
(#114 by @clue)
Feature: Update Socket dependency to support hosts file on all platforms
(#108 by @clue)
This means that HTTP requests to hosts such as localhost
will now work as
expected across all platforms with no changes required:
$client = new Client($loop);
$request = $client->request('GET', 'http://localhost/');
$request->on('response', function (Response $response) {
// …
});
$request->end();
Feature: Update DNS dependency to support hosts file on all platforms
(#112 by @clue)
This means that connecting to hosts such as localhost
will now work as
expected across all platforms with no changes required:
$connector = new Connector($loop);
$connector->connect('localhost:8080')->then(function ($connection) {
// …
});
Feature: Support resolving from default hosts file
(#75, #76 and #77 by @clue)
This means that resolving hosts such as localhost
will now work as
expected across all platforms with no changes required:
$resolver->resolve('localhost')->then(function ($ip) {
echo 'IP: ' . $ip;
});
The new HostsExecutor
exists for advanced usage and is otherwise used
internally for this feature.
Feature: Target evenement 3.0 a long side 2.0
(#106 by @WyriHaximus)
Improve test suite by locking Travis distro so new defaults will not break the build
(#105 by @clue)
RuntimeException
)Feature: Forward compatibility with upcoming EventLoop v1.0 and v0.5 and
target evenement 3.0 a long side 2.0 and 1.0
(#104 by @clue and #111 by @WyriHaximus)
Improve test suite by locking Travis distro so new defaults will not break the build and
fix HHVM build for now again and ignore future HHVM build errors
(#109 and #110 by @clue)
Minor documentation fixes
(#103 by @christiaan and #108 by @hansott)
Feature: Support Throwable
when setting previous exception from server callback
(#155 by @jsor)
Fix: Fixed URI parsing for origin-form requests that contain scheme separator
such as /path?param=http://example.com
.
(#209 by @aaronbonneau)
Improve test suite by locking Travis distro so new defaults will not break the build
(#211 by @clue)
Feature: Forward compatibility with EventLoop v1.0 and v0.5 and
lock minimum dependencies and work around circular dependency for tests
(#70 and #71 by @clue)
Fix: Work around DNS timeout issues for Windows users
(#74 by @clue)
Documentation and examples for advanced usage
(#66 by @WyriHaximus)
Remove broken TCP code, do not retry with invalid TCP query
(#73 by @clue)
Improve test suite by fixing HHVM build for now again and ignore future HHVM build errors and
lock Travis distro so new defaults will not break the build and
fix failing tests for PHP 7.1
(#68 by @WyriHaximus and #69 and #72 by @clue)
Feature: Target evenement 3.0 a long side 2.0 and 1.0
(#16 by @WyriHaximus)
Feature: Forward compatibility with EventLoop v1.0 and v0.5
(#18 by @clue)
Improve test suite by updating Travis build config so new defaults do not break the build
(#17 by @clue)
Feature: Only start timers if input Promise is still pending and
return a settled output promise if the input is already settled.
(#25 by @clue)
Feature: Cap minimum timer interval at 1µs across all versions
(#23 by @clue)
Feature: Forward compatibility with EventLoop v1.0 and v0.5
(#27 by @clue)
Improve test suite by adding PHPUnit to require-dev and
lock Travis distro so new defaults will not break the build
(#24 and #26 by @clue)
Fix: Stricter check for invalid request-line in HTTP requests
(#206 by @clue)
Refactor to use HTTP response reason phrases from response object
(#205 by @clue)
Feature: Support passing arrays for request header values
(#100 by @clue)
Fix: Fix merging default headers if overwritten with custom case headers
(#101 by @clue)
Feature: Emit error
event if request URL is invalid
(#99 by @clue)
Feature: Support OPTIONS method with asterisk-form (OPTIONS * HTTP/1.1
)
(#98 by @clue)
Fix: Fix parsing CONNECT request without Host
header
(#201 by @clue)
Internal preparation for future PSR-7 UploadedFileInterface
(#199 by @WyriHaximus)
Feature / BC break: Use PSR-7 (http-message) standard and
Request-In-Response-Out
-style request handler callback.
Pass standard PSR-7 ServerRequestInterface
and expect any standard
PSR-7 ResponseInterface
in return for the request handler callback.
(#146 and #152 and #170 by @legionth)
// old
$app = function (Request $request, Response $response) {
$response->writeHead(200, array('Content-Type' => 'text/plain'));
$response->end("Hello world!\n");
};
// new
$app = function (ServerRequestInterface $request) {
return new Response(
200,
array('Content-Type' => 'text/plain'),
"Hello world!\n"
);
};
A Content-Length
header will automatically be included if the size can be
determined from the response body.
(#164 by @maciejmrozinski)
The request handler callback will automatically make sure that responses to
HEAD requests and certain status codes, such as 204
(No Content), never
contain a response body.
(#156 by @clue)
The intermediary 100 Continue
response will automatically be sent if
demanded by a HTTP/1.1 client.
(#144 by @legionth)
The request handler callback can now return a standard Promise
if
processing the request needs some time, such as when querying a database.
Similarly, the request handler may return a streaming response if the
response body comes from a ReadableStreamInterface
or its size is
unknown in advance.
// old
$app = function (Request $request, Response $response) use ($db) {
$db->query()->then(function ($result) use ($response) {
$response->writeHead(200, array('Content-Type' => 'text/plain'));
$response->end($result);
});
};
// new
$app = function (ServerRequestInterface $request) use ($db) {
return $db->query()->then(function ($result) {
return new Response(
200,
array('Content-Type' => 'text/plain'),
$result
);
});
};
Pending promies and response streams will automatically be canceled once the
client connection closes.
(#187 and #188 by @clue)
The ServerRequestInterface
contains the full effective request URI,
server-side parameters, query parameters and parsed cookies values as
defined in PSR-7.
(#167 by @clue and #174, #175 and #180 by @legionth)
$app = function (ServerRequestInterface $request) {
return new Response(
200,
array('Content-Type' => 'text/plain'),
$request->getUri()->getScheme()
);
};
Advanced: Support duplex stream response for Upgrade
requests such as
Upgrade: WebSocket
or custom protocols and CONNECT
requests
(#189 and #190 by @clue)
Note that the request body will currently not be buffered and parsed by
default, which depending on your particilar use-case, may limit
interoperability with the PSR-7 (http-message) ecosystem.
The provided streaming request body interfaces allow you to perform
buffering and parsing as needed in the request handler callback.
See also the README and examples for more details.
Feature / BC break: Replace request
listener with callback function and
use listen()
method to support multiple listening sockets
(#97 by @legionth and #193 by @clue)
// old
$server = new Server($socket);
$server->on('request', $app);
// new
$server = new Server($app);
$server->listen($socket);
Feature: Support the more advanced HTTP requests, such as
OPTIONS * HTTP/1.1
(OPTIONS
method in asterisk-form),
GET http://example.com/path HTTP/1.1
(plain proxy requests in absolute-form),
CONNECT example.com:443 HTTP/1.1
(CONNECT
proxy requests in authority-form)
and sanitize Host
header value across all requests.
(#157, #158, #161, #165, #169 and #173 by @clue)
Feature: Forward compatibility with Socket v1.0, v0.8, v0.7 and v0.6 and
forward compatibility with Stream v1.0 and v0.7
(#154, #163, #183, #184 and #191 by @clue)
Feature: Simplify examples to ease getting started and
add benchmarking example
(#151 and #162 by @clue)
Improve test suite by adding tests for case insensitive chunked transfer
encoding and ignoring HHVM test failures until Travis tests work again.
(#150 by @legionth and #185 by @clue)
Feature / BC break: Replace Factory
with simple Client
constructor
(#85 by @clue)
The Client
now accepts a required LoopInterface
and an optional
ConnectorInterface
. It will now create a default Connector
if none
has been given.
// old
$dnsResolverFactory = new React\Dns\Resolver\Factory();
$dnsResolver = $dnsResolverFactory->createCached('8.8.8.8', $loop);
$factory = new React\HttpClient\Factory();
$client = $factory->create($loop, $dnsResolver);
// new
$client = new React\HttpClient\Client($loop);
Feature: Request::close()
now cancels pending connection attempt
(#91 by @clue)
Feature / BC break: Replace deprecated SocketClient with new Socket component
(#74, #84 and #88 by @clue)
Feature / BC break: Consistent stream semantics and forward compatibility with upcoming Stream v1.0
(#90 by @clue)
Feature: Forward compatibility with upcoming EventLoop v1.0 and v0.5
(#89 by @clue)
Feature: Add optional $writeChunkSize
parameter to limit maximum number of
bytes to write at once.
(#105 by @clue)
$stream = new WritableResourceStream(STDOUT, $loop, null, 8192);
Ignore HHVM test failures for now until Travis tests work again
(#106 by @clue)
clue/promise-stream-react
Feature: New Server
class now acts as a facade for existing server classes
and renamed old Server
to TcpServer
for advanced usage.
(#96 and #97 by @clue)
The Server
class is now the main class in this package that implements the
ServerInterface
and allows you to accept incoming streaming connections,
such as plaintext TCP/IP or secure TLS connection streams.
This is not a BC break and consumer code does not have to be updated.
Feature / BC break: All addresses are now URIs that include the URI scheme
(#98 by @clue)
- $parts = parse_url('tcp://' . $conn->getRemoteAddress());
+ $parts = parse_url($conn->getRemoteAddress());
Fix: Fix unix://
addresses for Unix domain socket (UDS) paths
(#100 by @clue)
Feature: Forward compatibility with Stream v1.0 and v0.7
(#99 by @clue)
Removed / BC break: Remove deprecated and unneeded functionality
(#45, #87, #90, #91 and #93 by @clue)
Remove deprecated Stream
class, use DuplexResourceStream
instead
(#87 by @clue)
Remove public $buffer
property, use new constructor parameters instead
(#91 by @clue)
Remove public $stream
property from all resource streams
(#90 by @clue)
Remove undocumented and now unused ReadableStream
and WritableStream
(#93 by @clue)
Feature / BC break: Simplify ThroughStream
by using data callback instead of
inheritance. It is now a direct implementation of DuplexStreamInterface
.
(#88 and #89 by @clue)
$through = new ThroughStream(function ($data) {
return json_encode($data) . PHP_EOL;
});
$through->on('data', $this->expectCallableOnceWith("[2, true]\n"));
$through->write(array(2, true));
Feature / BC break: The CompositeStream
starts closed if either side is
already closed and forwards pause to pipe source on first write attempt.
(#96 and #103 by @clue)
If either side of the composite stream closes, it will also close the other
side. We now also ensure that if either side is already closed during
instantiation, it will also close the other side.
BC break: Mark all classes as final
and
mark internal API as private
to discourage inheritance
(#95 and #99 by @clue)
Feature / BC break: Only emit error
event for fatal errors
(#92 by @clue)
The
error
event was previously also allowed to be emitted for non-fatal
errors, but our implementations actually only ever emitted this as a fatal
error and then closed the stream.
Feature: Explicitly allow custom events and exclude any semantics
(#97 by @clue)
Support legacy PHP 5.3 through PHP 7.1 and HHVM and improve usage documentation
(#100 and #102 by @clue)
Actually require all dependencies so this is self-contained and improve
forward compatibility with EventLoop v1.0 and v0.5
(#94 and #98 by @clue)
This is a bug fix and improvement release:
Feature: Merge SocketClient component into this component
(#87 by @clue)
This means that this package now provides async, streaming plaintext TCP/IP
and secure TLS socket server and client connections for ReactPHP.
$connector = new React\Socket\Connector($loop);
$connector->connect('google.com:80')->then(function (ConnectionInterface $conn) {
$connection->write('…');
});
Accordingly, the ConnectionInterface
is now used to represent both incoming
server side connections as well as outgoing client side connections.
If you've previously used the SocketClient component to establish outgoing
client connections, upgrading should take no longer than a few minutes.
All classes have been merged as-is from the latest v0.7.0
release with no
other changes, so you can simply update your code to use the updated namespace
like this:
// old from SocketClient component and namespace
$connector = new React\SocketClient\Connector($loop);
$connector->connect('google.com:80')->then(function (ConnectionInterface $conn) {
$connection->write('…');
});
// new
$connector = new React\Socket\Connector($loop);
$connector->connect('google.com:80')->then(function (ConnectionInterface $conn) {
$connection->write('…');
});
Feature: Add LimitingServer
to limit and keep track of open connections
(#86 by @clue)
$server = new Server(0, $loop);
$server = new LimitingServer($server, 100);
$server->on('connection', function (ConnectionInterface $connection) {
$connection->write('hello there!' . PHP_EOL);
…
});
Feature / BC break: Add pause()
and resume()
methods to limit active
connections
(#84 by @clue)
$server = new Server(0, $loop);
$server->pause();
$loop->addTimer(1.0, function() use ($server) {
$server->resume();
});
Feature / BC break: Add main Connector
facade
(#93 by @clue)
The new Connector
class acts as a facade for all underlying connectors,
which are now marked as "advanced usage", but continue to work unchanged.
This now makes it trivially easy to create plaintext TCP/IP, secure TLS and
Unix domain socket (UDS) connection streams simply like this:
$connector = new Connector($loop);
$connector->connect('tls://google.com:443')->then(function (ConnectionInterface $conn) {
$conn->write("GET / HTTP/1.0\r\n\r\n");
});
Optionally, it accepts options to configure all underlying connectors, such
as using a custom DNS setup, timeout values and disabling certain protocols
and much more. See the README for more details.
Feature / Fix / BC break: Add DuplexResourceStream
and deprecate Stream
(#85 by @clue)
// old (does still work for BC reasons)
$stream = new Stream($connection, $loop);
// new
$stream = new DuplexResourceStream($connection, $loop);
Note that the DuplexResourceStream
now rejects read-only or write-only
streams, so this may affect BC. If you want a read-only or write-only
resource, use ReadableResourceStream
or WritableResourceStream
instead of
DuplexResourceStream
.
BC note: This class was previously called
Stream
. TheStream
class still
exists for BC reasons and will be removed in future versions of this package.
Feature / BC break: Add WritableResourceStream
(previously called Buffer
)
(#84 by @clue)
// old
$stream = new Buffer(STDOUT, $loop);
// new
$stream = new WritableResourceStream(STDOUT, $loop);
Feature: Add ReadableResourceStream
(#83 by @clue)
$stream = new ReadableResourceStream(STDIN, $loop);
Fix / BC Break: Enforce using non-blocking I/O
(#46 by @clue)
BC note: This is known to affect process pipes on Windows which do not
support non-blocking I/O and could thus block the whole EventLoop previously.
Feature / Fix / BC break: Consistent semantics for
DuplexStreamInterface::end()
to ensure it SHOULD also end readable side
(#86 by @clue)
Fix: Do not use unbuffered reads on pipe streams for legacy PHP < 5.4
(#80 by @clue)
Ease getting started by improving documentation and adding examples
(#33 and #34 by @clue)
First class support for PHP 5.3 through PHP 7.1 and HHVM
(#29 by @clue and #32 by @WyriHaximus)
require-dev
Feature: Forward compatibility with Stream v0.5
(#26 by @clue)
Improve test suite by removing AppVeyor and adding PHPUnit to require-dev
(#27 and #28 by @clue)
Feature: Forward compatibility with Stream v0.5 and upcoming v0.6
(#89 by @clue)
Fix: Fix examples to use updated API
(#88 by @clue)
Feature / BC break: The Request
and Response
objects now follow strict
stream semantics and their respective methods and events.
(#116, #129, #133, #135, #136, #137, #138, #140, #141 by @legionth
and #122, #123, #130, #131, #132, #142 by @clue)
This implies that the Server
now supports proper detection of the request
message body stream, such as supporting decoding chunked transfer encoding,
delimiting requests with an explicit Content-Length
header
and those with an empty request message body.
These streaming semantics are compatible with previous Stream v0.5, future
compatible with v0.5 and upcoming v0.6 versions and can be used like this:
$http->on('request', function (Request $request, Response $response) {
$contentLength = 0;
$request->on('data', function ($data) use (&$contentLength) {
$contentLength += strlen($data);
});
$request->on('end', function () use ($response, &$contentLength){
$response->writeHead(200, array('Content-Type' => 'text/plain'));
$response->end("The length of the submitted request body is: " . $contentLength);
});
// an error occured
// e.g. on invalid chunked encoded data or an unexpected 'end' event
$request->on('error', function (\Exception $exception) use ($response, &$contentLength) {
$response->writeHead(400, array('Content-Type' => 'text/plain'));
$response->end("An error occured while reading at length: " . $contentLength);
});
});
Similarly, the Request
and Response
now strictly follow the
close()
method and close
event semantics.
Closing the Request
does not interrupt the underlying TCP/IP in
order to allow still sending back a valid response message.
Closing the Response
does terminate the underlying TCP/IP
connection in order to clean up resources.
You should make sure to always attach a request
event listener
like above. The Server
will not respond to an incoming HTTP
request otherwise and keep the TCP/IP connection pending until the
other side chooses to close the connection.
Feature: Support HTTP/1.1
and HTTP/1.0
for Request
and Response
.
(#124, #125, #126, #127, #128 by @clue and #139 by @legionth)
The outgoing Response
will automatically use the same HTTP version as the
incoming Request
message and will only apply HTTP/1.1
semantics if
applicable. This includes that the Response
will automatically attach a
Date
and Connection: close
header if applicable.
This implies that the Server
now automatically responds with HTTP error
messages for invalid requests (status 400) and those exceeding internal
request header limits (status 431).
Feature / BC break: Consistent end
event semantics (EOF)
(#70 by @clue)
The end
event will now only be emitted for a successful end, not if the
stream closes due to an unrecoverable error
event or if you call close()
explicitly.
If you want to detect when the stream closes (terminates), use the close
event instead.
BC break: Remove custom (undocumented) full-drain
event from Buffer
(#63 and #68 by @clue)
The
full-drain
event was undocumented and mostly used internally.
Relying on this event has attracted some low-quality code in the past, so
we've removed this from the public API in order to work out a better
solution instead.
If you want to detect when the buffer finishes flushing data to the stream,
you may want to look into itsend()
method or theclose
event instead.
Feature / BC break: Consistent event semantics and documentation,
explicitly state when events will be emitted and which arguments they
receive.
(#73 and #69 by @clue)
The documentation now explicitly defines each event and its arguments.
Custom events and event arguments are still supported.
Most notably, all defined events only receive inherently required event
arguments and no longer transmit the instance they are emitted on for
consistency and performance reasons.
// old (inconsistent and not supported by all implementations)
$stream->on('data', function ($data, $stream) {
// process $data
});
// new (consistent throughout the whole ecosystem)
$stream->on('data', function ($data) use ($stream) {
// process $data
});
This mostly adds documentation (and thus some stricter, consistent
definitions) for the existing behavior, it does NOT define any major
changes otherwise.
Most existing code should be compatible with these changes, unless
it relied on some undocumented/unintended semantics.
Feature / BC break: Consistent method semantics and documentation
(#72 by @clue)
This mostly adds documentation (and thus some stricter, consistent
definitions) for the existing behavior, it does NOT define any major
changes otherwise.
Most existing code should be compatible with these changes, unless
it relied on some undocumented/unintended semantics.
Feature: Consistent pipe()
semantics for closed and closing streams
(#71 from @clue)
The source stream will now always be paused via pause()
when the
destination stream closes. Also, properly stop piping if the source
stream closes and remove all event forwarding.
Improve test suite by adding PHPUnit to require-dev
and improving coverage.
(#74 and #75 by @clue, #66 by @nawarian)
TimeoutExecutor
and simplify internal APIs to allow internalFeature / BC break: Use connect($uri)
instead of create($host, $port)
and resolve with a ConnectionInterface
instead of Stream
and expose remote and local addresses through this interface
and remove superfluous and undocumented ConnectionException
.
(#74, #82 and #84 by @clue)
// old
$connector->create('google.com', 80)->then(function (Stream $conn) {
echo 'Connected' . PHP_EOL;
$conn->write("GET / HTTP/1.0\r\n\r\n");
});
// new
$connector->connect('google.com:80')->then(function (ConnectionInterface $conn) {
echo 'Connected to ' . $conn->getRemoteAddress() . PHP_EOL;
$conn->write("GET / HTTP/1.0\r\n\r\n");
});
Note that both the old
Stream
and the newConnectionInterface
implement
the same underlyingDuplexStreamInterface
, so their streaming behavior is
actually equivalent.
In order to upgrade, simply use the new typehints.
Existing stream handlers should continue to work unchanged.
Feature / BC break: All connectors now MUST offer cancellation support.
You can now rely on getting a rejected promise when calling cancel()
on a
pending connection attempt.
(#79 by @clue)
// old: promise resolution not enforced and thus unreliable
$promise = $connector->create($host, $port);
$promise->cancel();
$promise->then(/* MAY still be called */, /* SHOULD be called */);
// new: rejecting after cancellation is mandatory
$promise = $connector->connect($uri);
$promise->cancel();
$promise->then(/* MUST NOT be called */, /* MUST be called */);
Note that this behavior is only mandatory for pending connection attempts.
Once the promise is settled (resolved), callingcancel()
will have no effect.
BC break: All connector classes are now marked final
and you can no longer extend
them
(which was never documented or recommended anyway).
Please use composition instead of extension.
(#85 by @clue)
Feature / BC break: Change Request
methods to be in line with PSR-7
(#117 by @clue)
getQuery()
to getQueryParams()
getHttpVersion()
to getProtocolVersion()
getHeaders()
to always return an array of string valuesFeature / BC break: Update Socket component to v0.5 and
add secure HTTPS server support
(#90 and #119 by @clue)
// old plaintext HTTP server
$socket = new React\Socket\Server($loop);
$socket->listen(8080, '127.0.0.1');
$http = new React\Http\Server($socket);
// new plaintext HTTP server
$socket = new React\Socket\Server('127.0.0.1:8080', $loop);
$http = new React\Http\Server($socket);
// new secure HTTPS server
$socket = new React\Socket\Server('127.0.0.1:8080', $loop);
$socket = new React\Socket\SecureServer($socket, $loop, array(
'local_cert' => __DIR__ . '/localhost.pem'
));
$http = new React\Http\Server($socket);
BC break: Mark internal APIs as internal or private and
remove unneeded ServerInterface
(#118 by @clue, #95 by @legionth)
Feature / BC break: Replace listen()
call with URIs passed to constructor
and reject listening on hostnames with InvalidArgumentException
and replace ConnectionException
with RuntimeException
for consistency
(#61, #66 and #72 by @clue)
// old
$server = new Server($loop);
$server->listen(8080);
// new
$server = new Server(8080, $loop);
Similarly, you can now pass a full listening URI to the constructor to change
the listening host:
// old
$server = new Server($loop);
$server->listen(8080, '127.0.0.1');
// new
$server = new Server('127.0.0.1:8080', $loop);
Trying to start listening on (DNS) host names will now throw an
InvalidArgumentException
, use IP addresses instead:
// old
$server = new Server($loop);
$server->listen(8080, 'localhost');
// new
$server = new Server('127.0.0.1:8080', $loop);
If trying to listen fails (such as if port is already in use or port below
1024 may require root access etc.), it will now throw a RuntimeException
,
the ConnectionException
class has been removed:
// old: throws React\Socket\ConnectionException
$server = new Server($loop);
$server->listen(80);
// new: throws RuntimeException
$server = new Server(80, $loop);
Feature / BC break: Rename shutdown()
to close()
for consistency throughout React
(#62 by @clue)
// old
$server->shutdown();
// new
$server->close();
Feature / BC break: Replace getPort()
with getAddress()
(#67 by @clue)
// old
echo $server->getPort(); // 8080
// new
echo $server->getAddress(); // 127.0.0.1:8080
Feature / BC break: getRemoteAddress()
returns full address instead of only IP
(#65 by @clue)
// old
echo $connection->getRemoteAddress(); // 192.168.0.1
// new
echo $connection->getRemoteAddress(); // 192.168.0.1:51743
Feature / BC break: Add getLocalAddress()
method
(#68 by @clue)
echo $connection->getLocalAddress(); // 127.0.0.1:8080
BC break: The Server
and SecureServer
class are now marked final
and you can no longer extend
them
(which was never documented or recommended anyway).
Public properties and event handlers are now internal only.
Please use composition instead of extension.
(#71, #70 and #69 by @clue)
Feature: Add request header accessors (Ã la PSR-7)
(#103 by @clue)
// get value of host header
$host = $request->getHeaderLine('Host');
// get list of all cookie headers
$cookies = $request->getHeader('Cookie');
Feature: Forward pause()
and resume()
from Request
to underlying connection
(#110 by @clue)
// support back-pressure when piping request into slower destination
$request->pipe($dest);
// manually pause/resume request
$request->pause();
$request->resume();
Fix: Fix 100-continue
to be handled case-insensitive and ignore it for HTTP/1.0.
Similarly, outgoing response headers are now handled case-insensitive, e.g
we no longer apply chunked transfer encoding with mixed-case Content-Length
.
(#107 by @clue)
// now handled case-insensitive
$request->expectsContinue();
// now works just like properly-cased header
$response->writeHead($status, array('content-length' => 0));
Fix: Do not emit empty data
events and ignore empty writes in order to
not mess up chunked transfer encoding
(#108 and #112 by @clue)
Lock and test minimum required dependency versions and support PHPUnit v5
(#113, #115 and #114 by @andig)
data
listener if HeaderParser
emits an errorServer
null
for unknown addressesServerInterface
and lock test suite requirementsBuffer
can now be injected into the Stream
(or be used standalone)close
event only once for CompositeStream
and ThroughStream
close
event behavior for Buffer
null
for unknown addressesSecureServer
for secure TLS connectionsThis is a compatibility release that eases upgrading to the v0.4 release branch.
You should consider upgrading to the v0.4 release branch.
ConnectorInterface
Revert automatic cancellation of pending collection promises once the output promise resolves. This was introduced in 42d86b7 (PR #36, released in v2.3.0) and was both unintended and backward incompatible.
If you need automatic cancellation, you can use something like:
function allAndCancel(array $promises)
{
return \React\Promise\all($promises)
->always(function() use ($promises) {
foreach ($promises as $promise) {
if ($promise instanceof \React\Promise\CancellablePromiseInterface) {
$promise->cancel();
}
}
});
}
all()
and map()
functions now preserve the order of the array (#77).
Fix circular references when resolving a promise with itself (#71).
SecureStream
with unlimited read buffer from react/stream v0.4.5ConnectionInterface
should extend DuplexStreamInterface
+ documentationThis is a bugfix release that resolves an issue introduced in the v0.4.5 release.
You should consider upgrading to the v0.5 release.
Feature: Support Promise cancellation for all connectors
(#71 by @clue)
$promise = $connector->create($host, $port);
$promise->cancel();
Feature: Add TimeoutConnector decorator
(#51 by @clue)
$timeout = new TimeoutConnector($connector, 3.0, $loop);
$timeout->create($host, $port)->then(function(Stream $stream) {
// connection resolved within 3.0s
});
null
(infinite)full-drain
event if Buffer
is closed during drain
eventerror
event and close Stream
when accessing the underlyingdata
event if nothing has been read (stream reached EOF)Buffer
Feature: Allow for cache adapter injection (#38 by @WyriHaximus)
$factory = new React\Dns\Resolver\Factory();
$cache = new MyCustomCacheInstance();
$resolver = $factory->createCached('8.8.8.8', $loop, $cache);
Feature: Support Promise cancellation (#35 by @clue)
$promise = $resolver->resolve('reactphp.org');
$promise->cancel();
some()
not cancelling pending promises when too much input promises reject (16ff799).resolve()
.then()
method is now assimilated to a trusted promise that follows the state of this thenable (#52).some()
and any()
for input arrays containing not enough items (#34).This is a compatibility release that backports some changes from the v0.5
release branch. You should consider upgrading to the v0.5 release.
\Throwable
in the same way as \Exception
(#51 by @joshdifabio).Feature / BC break: Support Connector without DNS
(#46 by @clue)
BC break: The Connector
class now serves as a BC layer only.
The TcpConnector
and DnsConnector
classes replace its functionality.
If you're merely using this class, then you're recommended to upgrade as
per the below snippet – existing code will still work unchanged.
If you're extend
ing the Connector
(generally not recommended), then you
may have to rework your class hierarchy.
// old (still supported, but marked deprecated)
$connector = new Connector($loop, $resolver);
// new equivalent
$connector = new DnsConnector(new TcpConnector($loop), $resolver);
// new feature: supports connecting to IP addresses only
$connector = new TcpConnector($loop);
Feature: Add socket and SSL/TLS context options to connectors
(#52 by @clue)
Fix: PHP 5.6+ uses new SSL/TLS context options
(#61 by @clue)
Fix: Move SSL/TLS context options to SecureConnector
(#43 by @clue)
Fix: Fix error reporting for invalid addresses
(#47 by @clue)
Fix: Close stream resource if connection fails
(#48 by @clue)
First class support for PHP 5.3 through PHP 7 and HHVM
(#53, #54 by @clue)
Add integration tests for SSL/TLS sockets
(#62 by @clue)
DeferredPromise
to also implement the CancellablePromiseInterface
.This release makes the API more compatible with 2.0 while preserving full backward compatibility.
This release makes the API more compatible with 2.0 while preserving full backward compatibility.
React\Promise\Promise
class.React\Promise\When
and React\Promise\Util
to functions while keeping the classes as a proxy for BC.This release introduces the ExtendedPromiseInterface.
The ExtendedPromiseInterface extends the PromiseInterface with useful shortcut
and utility methods which are not part of the Promises/A specification.
This project has been migrated over from clue/datagram
which has originally been released in January 2013.
Upgrading from clue/datagram v0.5.0? Use namespaceReact\Datagram
instead ofDatagram
and you're ready to go!
Phergilicious: In honour of all the SSL bugs found by the Phergie project re-writing on top of React.
Introduce new CancellablePromiseInterface implemented by all promises.
Backwards compatibility release for Reach 0.3.x and PHP 5.3 (see #4).
EventLoopInterface::nextTick()
, implemented in all event loops (@jmalloc)EventLoopInterface::futureTick()
, implemented in all event loops (@jmalloc)ExtEventLoop
implementation using pecl/event (@jmalloc)EventLoopInterface::nextTick()
EventLoopInterface::futureTick()
Response::getBody()
$loop
argument from HttpClient
: Client
, Request
, Response
New major release. The goal was to streamline the API and to make it more compliant with other promise libraries and especially with the new upcoming ES6 promises specification.
LibEvLoop
ReadableStreamInterface
on BufferedSink::createPromise()
When::lazy()
to create lazy promises which will be initialized once a consumer calls the then()
method.Imported release from original tag date 2013-02-06.
PromisorInterface
for objects that have a promise()
method.When::any()
not correctly unwrapping to a single result value$promiseOrValue
argument of When::resolve()
and When::reject()
is now optionalphp-libev
3.0.*
Buffer::write()