php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14371 RETURN_TRANSFER dies if site doesn't ping
Submitted: 2001-12-06 22:24 UTC Modified: 2001-12-31 10:42 UTC
From: me at hansanderson dot com Assigned:
Status: Closed Package: cURL related
PHP Version: 4.0.6 OS: Linux 2.2.12-20
Private report: No CVE-ID: None
 [2001-12-06 22:24 UTC] me at hansanderson dot com
Using --with-curl and "libcurl 7.8 (SSL 0.9.5)":

If you use the following function with a url that pings, but does not answer, it will die.  I have a script set up to continue for timeouts, but it does not continue, it dies.  If you change CURLOPT_RETURNTRANSFER to 0, it will not die, but also does not return the data in a variable as I need it to.

I would give you a url to try, but chances are that it will be back up by the time you get to this.  This works *fine* for sites not found, pages not found, dns errors, timeouts, etc.  It is only a problem if the computer is in the DNS records but does not respond (to ping).

function get_data($url, $timeout=15) {

        $timeout = (int)$timeout;
        $ch = curl_init ();
        curl_setopt ($ch, CURLOPT_URL, $url);
        curl_setopt ($ch, CURLOPT_MUTE, 0);
        curl_setopt ($ch, CURLOPT_TIMEOUT, $timeout);
        curl_setopt ($ch, CURLOPT_NOBODY, 0);
        curl_setopt ($ch, CURLOPT_HEADER, 0);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

        $page = curl_exec ($ch);
        #print curl_error($ch);
        #print "<br>";
        #print "page: $page";
        #$i = curl_getinfo($ch);
        #print_r($i);
        curl_close ($ch);

        return trim($page);
}

 './configure' '--with-apxs=/usr/sbin/apxs' '--prefix=/usr' '-with-config-file-path=/etc/httpd' '-enable-safe-mode' '--with-exec-dir=/usr/bin' '--with-system-regex' '--disable-debug' '--with-zlib' '-enable-debugger' '--enable-track-vars' '--enable-ftp' '--enable-wddx' '--with-gdbm' '--with-mysql=/usr' '--with-pgsql' '--with-xml' '--with-curl=/usr/local'


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-31 10:42 UTC] sterling@php.net
Fixed in cvs and 4.1.*
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 20:01:45 2024 UTC