php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27401 fopen problem
Submitted: 2004-02-26 05:57 UTC Modified: 2004-02-26 09:36 UTC
From: ycallen at ndsisrael dot com Assigned:
Status: Not a bug Package: Apache related
PHP Version: 4.3.4 OS: RHEL linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ycallen at ndsisrael dot com
New email:
PHP Version: OS:

 

 [2004-02-26 05:57 UTC] ycallen at ndsisrael dot com
Description:
------------
I do the following steps:
1.I run apache in debug mode(httpd -X).
2.I have a php script(send.php) that tries to access another php script(recieve.php)using fopen with a url.The url points to localhost[example : fopen("http://localhost/~php/recieve.php)].
3.The program hangs and eventually times out with the following warning : "Warning: fopen(http://localhost/~php/recieve.php?param1=1??m2=2): failed to open stream: HTTP request failed! ???^ in /home/php/public_html/send.php on line 6"

This only happens when i run apache in debug mode.When i run apache in regular mode then it works.

Reproduce code:
---------------
recieve.php:
<?php
echo "with GET<br>";
echo "my first param is: ".$_GET['param1']."<br>";
echo "my second param is: ".$_GET['param2']."<br>";
?>

send.php:
<?php
$url = "http://localhost/~php/recieve.php?param1=1&param2=2";
$opts = array('http' => array('method' => "GET"));
$context = stream_context_create($opts);
echo "before fopen<br>";
$fp = fopen($url, "r", true, $context);
fpassthru($fp);
fclose($fp);
?>

Expected result:
----------------
before fopen
with GET
my first param is: 1
my second param is: 2


Actual result:
--------------
before fopen

Warning: fopen(http://localhost/~php/recieve.php?param1=1??m2=2): failed to open stream: HTTP request failed! ???^ in /home/php/public_html/send.php on line 6

Warning: fpassthru(): supplied argument is not a valid stream resource in /home/php/public_html/send.php on line 7

Warning: fclose(): supplied argument is not a valid stream resource in /home/php/public_html/send.php on line 8


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-26 06:07 UTC] postings-php-bug at hans-spath dot de
What happens when you execute the following line on a shell?
wget -O - "http://localhost/~php/recieve.php?param1=1&param2=2"
 [2004-02-26 06:14 UTC] ycallen at ndsisrael dot com
it works using :

wget -O - "http://localhost/~php/recieve.php?param1=1&param2=2"
 [2004-02-26 07:17 UTC] sniper@php.net
Of course it times out in debug mode since there's only one child serving requests..and the one request is taken by your script calling the other script..

 [2004-02-26 07:22 UTC] ycallen at ndsisrael dot com
If that was the case then no php scripts would work at all.Basic php scripts work.The only problem i found so far was with fopen.
 [2004-02-26 07:27 UTC] sniper@php.net
You're using old version too. Latest stable CVS snapshot has lot of bugs fixed..

 [2004-02-26 07:27 UTC] ycallen at ndsisrael dot com
It's not an old version.It's one of the newer ones.
 [2004-02-26 09:36 UTC] ycallen at ndsisrael dot com
I redirected the fopen to another computer with apache runnning on it and it still didn't work.Do you always write bogus when there is a bug that you don't know how to fix?
 [2004-04-13 03:39 UTC] coadmin at hostings dot com dot pl
Hello,

I've similar problem. It's not bogus.
I use two servers: FreeBSD 4.9-STABLE and FreeBSD-5.2.1-p3 on different hardware. My PHP version is too 4.3.4 and PHP act as mod_php. Apache 1.3.29.

I've such messages in logs:

Warning:
fopen(http://xxx.foo/check_code.php?id=1707&code=xxx):
failed to open stream: HTTP request failed! @&#169;? in /home/xxx/public_html/check.php on line 20

Warning: fgets(): supplied argument is not a valid stream resource in
/home/xxx/public_html/check.php on line 21

Warning: fgets(): supplied argument is not a valid stream resource in
/home/xxx/public_html/check.php on line 22

Warning: fclose(): supplied argument is not a valid stream resource in
/home/xxx/public_html/check.php on line 23

The problem occurs randomly, about a few hours after Apache START. Only way to fix it is to do full restart of Apache. Problem locks functions fopen() and/or fsockopen(). I don't know how to reproduce it - only way is to wait a few hours. It seems that it's OS independent. Other php functions works good. I didn't noticed any problems. Plese help.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 13:01:35 2025 UTC