php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51852 file_get_contents not working with hhtp urls
Submitted: 2010-05-18 16:21 UTC Modified: 2010-05-18 17:11 UTC
From: laurent at roussanne dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.13 OS: windows server 2008 64 bits
Private report: No CVE-ID: None
 [2010-05-18 16:21 UTC] laurent at roussanne dot com
Description:
------------
file_get_contents("http://www.php.net");

reports : 
 failed to open stream: Une tentative de connexion a échoué car le parti connecté 
n'a pas répondu convenablement au-delà d'une certaine durée ou une connexion 
établie a échoué car l'hôte de connexion n'a pas répondu.




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-18 16:27 UTC] pajoye@php.net
-Status: Open +Status: Bogus
 [2010-05-18 16:27 UTC] pajoye@php.net
Works just fine. Verify your network connections or whatever you use to connect to internet. I suppose a simple: file_get_contents("http://127.0.01/"); will work just fine too for you (as long as you have 127.0.0.1 define).
 [2010-05-18 16:34 UTC] laurent at roussanne dot com
I worked to find a workaround all the last weekend.
the solution was writing this : 

function win64_file_get_contents($url, $timeout=5)
    {
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $file_contents = curl_exec($ch);
    curl_close($ch);
    if (is_bool($file_contents) && ($file_contents == FALSE))
        {
        return FALSE;
        }
    else
        {
        return $file_contents;
        }
    }


I'm sure you know this code (found on the web).

Do you have a windows 2008 64 test platform ?
 [2010-05-18 16:38 UTC] pajoye@php.net
Yes, windows is my main platform. Did you allow allow_url_fopen in your php.ini?

But again: It does work. If it does not, then something is wrong in your configuation.
 [2010-05-18 16:43 UTC] laurent at roussanne dot com
allow_url_include On On 

It is not a network problem because curl based workaround works !

I'm sure it is a windows 64 bits specific problem (2008 server, vista, or seven).
 [2010-05-18 16:56 UTC] pajoye@php.net
It is not. It works (win7/2k8/2k8R2, x64 or x86). Please ask further support on php-windows or php-general mailing list.
 [2010-05-18 17:11 UTC] laurent at roussanne dot com
perhaps a French windows 2008 server OS specific issue ?

The bug appears even with the command line interface.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 10:01:29 2024 UTC