php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53615 fopen/http(s) on cheap routers
Submitted: 2010-12-27 13:27 UTC Modified: 2016-08-04 13:46 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: hungry dot rahly at gmail dot com Assigned: nikic (profile)
Status: Closed Package: Streams related
PHP Version: 5.3SVN-2010-12-27 (SVN) OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hungry dot rahly at gmail dot com
New email:
PHP Version: OS:

 

 [2010-12-27 13:27 UTC] 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.


Patches

fopen-http-request (last revision 2010-12-27 12:30 UTC by hungry dot rahly at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-04 13:06 UTC] vhu at iki dot fi
Root cause seems to be the same as in #27814 and should be fixed in 7.1.
 [2016-08-04 13:46 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 17:01:32 2024 UTC