|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-05-29 17:34 UTC] bjori@php.net
-Status: Open
+Status: Bogus
[2011-05-29 17:34 UTC] bjori@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 15:00:01 2025 UTC |
Description: ------------ When I try to make HTTP keep-alive connection, script behaves ununderstood. When I am making two request per one connection, using header "Connection:keep- alive", script processes only one. Second request, although it was written into socket, it returns an empty result, due to the fact that the pointer is EOF. Test script: --------------- <?php /* file 1.txt on localhost contains text: 1 file 2.txt on localhost contains text: 2 */ function run($fp, $c, $u) { if ($fp) { fwrite($fp, "GET {$u} HTTP/1.0\r\nHost: localhost\r\nConnection: {$c}\r\n\r\n"); $data = ''; while (!feof($fp)) { $data .= fgets($fp); } return $data; } } //trying to use keep-alive $fp = stream_socket_client("tcp://localhost:80", $errno, $errstr, 30); echo run($fp, "keep-alive", "/1.txt"); echo run($fp, "keep-alive", "/2.txt"); fclose($fp); //trying to use close $fp = stream_socket_client("tcp://localhost:80", $errno, $errstr, 30); echo run($fp, "close", "/1.txt"); fclose($fp); $fp = stream_socket_client("tcp://localhost:80", $errno, $errstr, 30); echo run($fp, "close", "/2.txt"); fclose($fp); Expected result: ---------------- HTTP/1.1 200 OK Date: Tue, 24 May 2011 13:35:50 GMT Server: Apache Last-Modified: Tue, 24 May 2011 13:16:42 GMT ETag: "3200000001c164-3-4a405662479e4" Accept-Ranges: bytes Content-Length: 3 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/plain 1 HTTP/1.1 200 OK Date: Tue, 24 May 2011 13:35:50 GMT Server: Apache Last-Modified: Tue, 24 May 2011 13:16:42 GMT ETag: "3200000001c164-3-4a405662479e4" Accept-Ranges: bytes Content-Length: 3 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/plain 2 HTTP/1.1 200 OK Date: Tue, 24 May 2011 13:35:57 GMT Server: Apache Last-Modified: Tue, 24 May 2011 13:16:42 GMT ETag: "3200000001c164-3-4a405662479e4" Accept-Ranges: bytes Content-Length: 3 Connection: close Content-Type: text/plain 1 HTTP/1.1 200 OK Date: Tue, 24 May 2011 13:35:58 GMT Server: Apache Last-Modified: Tue, 24 May 2011 13:16:53 GMT ETag: "1700000001c166-1-4a40566ce2b4c" Accept-Ranges: bytes Content-Length: 1 Connection: close Content-Type: text/plain 2 Actual result: -------------- HTTP/1.1 200 OK Date: Tue, 24 May 2011 13:35:50 GMT Server: Apache Last-Modified: Tue, 24 May 2011 13:16:42 GMT ETag: "3200000001c164-3-4a405662479e4" Accept-Ranges: bytes Content-Length: 3 Keep-Alive: timeout=5, max=100 Connection: Keep-Alive Content-Type: text/plain 1 HTTP/1.1 200 OK Date: Tue, 24 May 2011 13:35:57 GMT Server: Apache Last-Modified: Tue, 24 May 2011 13:16:42 GMT ETag: "3200000001c164-3-4a405662479e4" Accept-Ranges: bytes Content-Length: 3 Connection: close Content-Type: text/plain 1 HTTP/1.1 200 OK Date: Tue, 24 May 2011 13:35:58 GMT Server: Apache Last-Modified: Tue, 24 May 2011 13:16:53 GMT ETag: "1700000001c166-1-4a40566ce2b4c" Accept-Ranges: bytes Content-Length: 1 Connection: close Content-Type: text/plain 2