Bug #53615 [Com]: fopen/http(s) on cheap routers
| From: | vhu at iki dot fi | Date: | Thu, 04 Aug 2016 13:06:03 +0000 |
| Subject: | Bug #53615 [Com]: fopen/http(s) on cheap routers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202925@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=53615&edit=1
ID: 53615
Comment by: vhu at iki dot fi
Reported by: hungry dot rahly at gmail dot com
Summary: fopen/http(s) on cheap routers
Status: Open
Type: Bug
Package: Streams related
Operating System: linux
PHP Version: 5.3SVN-2010-12-27 (SVN)
Block user comment: N
Private report: N
New Comment:
Root cause seems to be the same as in #27814 and should be fixed in 7.1.
Previous Comments:
------------------------------------------------------------------------
[2010-12-27 13:27:54] hungry dot rahly at gmail dot com
Description:
------------
fopen fails(sometimes, as heavier system loads it will be successful, and less load fails) web
requests using http/https when behind cheap routers with content filtering on. This is due to how
php sends headers.
how php runs.
php_stream_write("GET / HTTP/1.0\r\n");
php_stream_write("Host: www.hostname.com\r\n");
php_stream_write("\r\n");
This potentially forces 3 packet sends where cheaper hardware cannot reconstruct the request
entirely. Since content filters need to know the host, the hardware fails after it gets the
"GET" and hangs.
Changing the code to a minimum of
php_stream_write("GET / HTTP/1.0\r\nHost: www.hostname.com\r\n");
php_stream_write("\r\n");
this will force the GET and the Host line to be in the same packet. Enough for cheap hardware to
see it and handle appropriately.
also, opening a socket and handling the http protocol manually, works fine.
The attached patch, works, but would like to test more to make sure it doesn't cause any other
problems.
Test script:
---------------
$web = fopen("http://www.google.com/",
"r"); // need cheap hardware with content filtering turned on
Expected result:
----------------
On cheap hardware, it will timeout and not perform the request.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=53615&edit=1