Re: file_get_contents ($file) works -- file_get_contents ($url) returns false
| From: | René Fournier | Date: | Wed, 16 Dec 2009 04:49:23 +0000 |
| Subject: | Re: file_get_contents ($file) works -- file_get_contents ($url) returns false | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-300543@lists.php.net to get a copy of this message | ||
On 2009-12-15, at 11:55 PM, Richard Quadling wrote:
> Do you have a default stream context defined for the http stream?
Nope.
>
> A _LONG_ time ago, when I was using a firewall with NTLM
> authentication (which PHP doesn't deal with), I had to route all my
> calls through a local proxy.
>
> This was the code I had ...
>
> <?php
> // Define the default, system-wide context.
> $r_default_context = stream_context_get_default(
> array(
> 'http' => array( // All HTTP requests are passed through the local
> NTLM proxy server on port 8080.
> 'proxy' => 'tcp://127.0.0.1:8080',
> 'request_fulluri' => True,
> ),
> )
> );
>
> // Though we said system wide, some extensions need a little coaxing.
> libxml_set_streams_context($r_default_context);
>
>
> Now, you may not see this in your code, but may be in a script which
> is loaded via auto_prepend_file.
Wish it were, but my test code is bare bones.
>
> I would also suggest running something like WireShark at the same time
> as your script. See if there is ANY traffic over the wire.
>
> Do the cURL and file_get_contents() code generate identical requests?
cURL -- both PHP and command-line -- fetches files and URLs (remote and local) w/o issues.
file_get_contents() fetches files, but fails on all URLs (remote and local). This is why I believe
the problem lies with the machine's configuration and not the Firewall.
It's pretty confounding, isn't it? I'm not sure what to do at this point.
...Rene