Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 21, 2023

Conversation

clue
Copy link
Member

@clue clue commented Apr 19, 2023

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.x Apr 21, 2023
@WyriHaximus
Copy link
Member

🚀 🚀 🚀 🚀 🚀 !

@clue clue deleted the keep-alive-default branch April 21, 2023 10:53
Sign up for free to 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