HTTP server: Persistent connection on HTTP/1.0 hangs, when using streaming response body
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 76/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- PHP
- Sterne
- 781
- Forks
- 166
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus reactphp/http
-
bug
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 35/100
-
maintenance
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 20/100
-
new feature
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
-
help wanted new feature
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
-
new feature
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
getgrav/grav-plugin-api#45 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
RSS-Bridge/rss-bridge#5098 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
phingofficial/phing#2025 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
silverstripe/developer-docs#911 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100