HTTP server: Persistent connection on HTTP/1.0 hangs, when using streaming response body
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 76/100
Piste de recherche
Start at src/Io/StreamingServer.php around line 308 and reproduce the issue with the provided streaming ThroughStream example and curl --http1.0 request. Trace how an HTTP/1.0 response with an unknown body size handles Connection: keep-alive; done means the response is transmitted and the connection closes instead of hanging.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Assuming the response body is streaming and its size is unknown, when a request such as this is received:
GET / HTTP/1.0
Connection: keep-alive
ReactPHP produces a response without a Content-Length header, such as this:
HTTP/1.0 200 OK
Connection: keep-alive
<data>
and doesn't close the connection, which then just hangs until timeout, because for the client there is no way of telling, when the response data is finished transmitting.
Steps to reproduce:
$server = new React\Http\HttpServer(function () {
$stream = new ThroughStream();
Loop::futureTick(function () use ($stream) {
$stream->write("foo\n");
$stream->end();
});
return new Response(200, body: $stream);
});
$socket = new React\Socket\SocketServer("0.0.0.0:80");
$server->listen($socket);
curl -v --http1.0 -H "connection: keep-alive" localhost:80
Tested on v1.11.0 and 3.x-dev (4e1b4f369eea9428ac38b8851e113ce5ad47cbee).
Since it's HTTP/1.0, Transfer-Encoding: chunked cannot be used. I believe the only good way to handle this situation is to ignore the requested Connection: keep-alive and just close the connection after the response is transmitted. I think this should be a valid behavior - server is not required to strictly obey the keep-alive request header.
The relevant code is here: https://github.com/reactphp/http/blob/1.x/src/Io/StreamingServer.php#L308
- Langage dominant
- PHP
- Étoiles
- 781
- Forks
- 166
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de reactphp/http
-
bug
Difficulté 3/5 1-2 jours Accessibilité débutants 35/100
-
Roadmap to reactphp/http v3 Ouvertemaintenance
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
-
new feature
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
-
help wanted new feature
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
-
new feature
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
Toutes les issues de reactphp/http
Issues similaires
-
sync-en
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
-
sync-en
Difficulté 1/5 1-3 heures Accessibilité débutants 85/100
-
Перевод устарел
Difficulté 1/5 1-3 heures Accessibilité débutants 78/100
-
[6.x]: "Cannot use object of type stdClass as array" loading Users index (regression of #19182) Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100