Skip to content

Enable HTTP keep-alive by default for HTTP client - #495

Merged
WyriHaximus merged 1 commit into
reactphp:1.xfrom
clue-labs:keep-alive-default
Apr 21, 2023
Merged

Enable HTTP keep-alive by default for HTTP client#495
WyriHaximus merged 1 commit into
reactphp:1.xfrom
clue-labs:keep-alive-default

Conversation

@clue

@clueclue commented Apr 19, 2023

Copy link
Copy Markdown
Member

This changeset enables HTTP keep-alive by default for the HTTP client. HTTP keep-alive (reusing persistent connections) 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.

HTTP keep-alive is now enabled by default. If you do not want to use HTTP keep-alive, you can disable this feature by sending a Connection: close HTTP request header or by using HTTP/1.0 like this:

// not recommended: add `Connection: close` request header to disable HTTP keep-alive$browser = $browser->withHeader('Connection', 'close');
// not recommended: use HTTP/1.0 to disable HTTP keep-alive$browser = $browser->withProtocolVersion('1.0');

We've done some careful testing in PR #486 and our sophisticated test suite that covers tests against both well-behaving and misbehaving HTTP servers that might occur in the wild. On top of this, we've done some extensive tests in real-world applications in the past weeks after merging this feature. The test suite confirms this has 100% code coverage and does not otherwise affect our public APIs. If you encounter any issues with this in the wild, please confirm by disabling HTTP keep-alive and report a bug ticket in this case. If you'd like to support this development, consider sponsoring ReactPHP! ❤️

Builds on top of #486, #484 and others
Refs #488, #468 and others

@WyriHaximus
WyriHaximus merged commit 7189c6a into reactphp:1.xApr 21, 2023
@WyriHaximus

Copy link
Copy Markdown
Member

🚀 🚀 🚀 🚀 🚀 !

@clue
clue deleted the keep-alive-default branch April 21, 2023 10:53
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@clue@WyriHaximus@SimonFrings