ID: 29280
Comment by: Progman2002 at web dot de
Reported By: Progman2002 at gmx dot de
Status: Feedback
Bug Type: *Network Functions
PHP Version: Irrelevant
New Comment:
sure:
---- PHP-Code:
<?php
$opts = array('http' => array('request_fulluri' => true,
'proxy' =>
'tcp://192.168.0.1:8080'));
$context = stream_context_create($opts);
$url = "http://www.example.com/";
$fp = fopen($url, 'r', false, $context);
if (!$fp) {
echo "nothing :(";
} else {
var_dump($fp);
fclose($fp);
}
// and now without $context...
$fp = fopen($url, 'r');
if (!$fp) {
echo "nothing :(";
} else {
var_dump($fp);
fclose($fp);
}
?>
The first call with $context works, the second doesnt:
---- Output:
resource(3) of type (stream)
Warning: fopen(http://www.example.com/) [function.fopen]: failed to
open stream: Connection timed out in /home/progman/public_html/test.php
on line 19
nothing :(
---- Expected:
resource(3) of type (stream)
resource(4) of type (stream) // or an other resource-id
----
A php.ini-setting for proxys would be maybe better ;)
Previous Comments:
------------------------------------------------------------------------
[2004-07-20 14:24:46] [EMAIL PROTECTED]
I know what you mean (and we do have something planned), but can you
please clarify which functions you are using to implement proxy
support?
------------------------------------------------------------------------
[2004-07-20 14:01:48] Progman2002 at gmx dot de
Description:
------------
I'm behind a proxy so my local php version cannot access the internet
directly. Every HTTP-Request must go throught the proxy. I have see
that I can create my own http-wrapper with settings to use my proxy and
use this metioned "context" as fourth parameter for the functions like
fopen and file_get_contents. This works fine, but what about if I use
third-party scripts, which just use file_get_contents($url) instead of
file_get_contents($url, false, $context)? It is possible to change or
modify the internal http-wrapper to use my proxy instead of creating a
new http-wrapper with stream_*() so I can just use file_get_contents()
and fopen() without the 'zcontext'-parameter?
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29280&edit=1