From:
Operating system: linux
PHP version: 5.3SVN-2010-12-27 (SVN)
Package: Streams related
Bug Type: Bug
Bug description:fopen/http(s) on cheap routers
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 bug report at http://bugs.php.net/bug.php?id=53615&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53615&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53615&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53615&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53615&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53615&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53615&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53615&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53615&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53615&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53615&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53615&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53615&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53615&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53615&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53615&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53615&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53615&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53615&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53615&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53615&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53615&r=mysqlcfg