Bug #14371 Updated: RETURN_TRANSFER dies if site doesn't ping
| From: | sterling@php.net | Date: | Mon, 31 Dec 2001 15:42:53 +0000 |
| Subject: | Bug #14371 Updated: RETURN_TRANSFER dies if site doesn't ping | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-75434@lists.php.net to get a copy of this message | ||
ID: 14371
Updated by: sterling
Reported By: me@hansanderson.com
Old Status: Open
Status: Closed
Bug Type: cURL related
Operating System: Linux 2.2.12-20
PHP Version: 4.0.6
New Comment:
Fixed in cvs and 4.1.*
Previous Comments:
------------------------------------------------------------------------
[2001-12-06 22:24:27] me@hansanderson.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'
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=14371&edit=1