-
Notifications
You must be signed in to change notification settings - Fork 2
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
Keepalive #13
Labels
Comments
💡 Idea no. 1$conn= new HttpConnection(...);
$conn->useKeepAlive(); // Use default strategy
$conn->useKeepAlive(newinstance(KeepAlive::class, [], [
'timeout' => function($request, $response) {
if ('example.com' === $request->url->getHost()) {
return 0.0; // Close immediately
} else {
return 30.0; // Keep open for 30.0 seconds
}
}
])); |
💡 Idea no. 2$conn= new HttpConnection(...);
$conn->usingKeepAlive(function() {
$r1= $conn->get(...);
$r1->abort(); // Do not process content until end
$r2= $conn->post(...);
Streams::readAll($r2->in());
}); |
💡 Idea no. 3$conn= new HttpConnection(...);
$req= $conn->create(new HttpRequest())->keepAlive();
$req= $conn->create(new HttpRequest())->keepAlive(newinstance(KeepAlive::class, [], [
// See idea #1 above
])));
$res= $conn->send($req); |
💡 Idea no. 4$conn= new HttpConnection(...);
$conn->get(..., function($res) {
$res->abort();
// or: Streams::readAll($res->in());
}); |
💡 Idea no. 5$conn= new HttpConnection(...);
$pool= $conn->pool(5);
$pool->get()->then(function($res) {
// Uses first socket
});
$pool->post()->then(function($res) {
// Uses first *free* socket within the pool
}); |
See #22 - this is now implemented by passing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HTTP Connections should support Keep-Alive.
Further reading
http://docs.oracle.com/javase/7/docs/technotes/guides/net/http-keepalive.html
http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html
https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.keepalive(v=vs.110).aspx
nodejs/node-v0.x-archive#4769
https://github.com/billywhizz/node-httpclient
The text was updated successfully, but these errors were encountered: