pecl_http unsuppressible error messages
| From: | Brian Thompson | Date: | Wed, 05 Mar 2008 22:56:09 +0000 |
| Subject: | pecl_http unsuppressible error messages | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-5163@lists.php.net to get a copy of this message | ||
Hello,
I'm trying to use pecl_http to check the validity of a link taken as input.
It's working quite nicely except in one case: When I call a server and get a
request timeout, an error message gets echoed to the output stream no matter
what I try to do to suppress it.
My code:
//try {
//error_reporting(0);
$response = @http_head($url, array("timeout"=>1), $info);
$parsedResponse = http_parse_headers($response);
echo "responseCode = " . $parsedResponse['Response Code'] . ";\n";
echo "responseStatus = '" . $parsedResponse['Response Status'] .
"';\n";
//} catch(Exception $e) {
// //handle error
//}
With or without the '@', with or without the commented lines, I consistently get
the PHP error table giving the following message before my echoed text appears:
Sorry, an error has occurred with this website. The staff have been informed,
and it will be fixed as soon as possible
ERROR: http_head() [function.http-head]: a timeout was reached; Operation timed
out after 1 seconds with 0 bytes received (http://offending.url/)
Does anyone have any thoughts on how I could suppress the timeout message? When
I put this into production, I'll increase the timeout value, but I still need to
catch request timeouts explicitly and issue a custom error message rather than
echoing HTML to a page that isn't supposed to be HTML.
Thanks,
-Brian