Home » HTTP » HTTP_Request » Bug #6610
"Connection refused" dies hard
Details
| Submitted | 2006-01-27 18:06 UTC |
|---|---|
| From | serendipity at garv dot in |
| Status | Bogus |
| Package | HTTP_Request |
| PHP Version | 4.4.1 |
| OS | Linux |
| Roadmaps | (Not assigned) |
Comments
[2006-01-27 18:06 UTC] serendipity at garv dot in
Description:
------------
Doing a HTTP_Request to a Host that replies with "Connection refused" makes PEAR die quite hard.
The code below is a snippet from Serendipity, where this bug leads to a full stop of Serendipity. It dies with these messages:
Connection refused
Notice: Connection refused in /home/garvin/cvs/serendipity/trunk/bundled-libs/PEAR.php on line 848
Connection refused
It would be nice, if this would not stop the whole process. :-)
I hope that HTTP_Request is the right place to support this. I am not sure if it is a central PEAR.php or Net_Socket/URL problem.
Test script:
---------------
<?php
require_once S9Y_PEAR_PATH . 'HTTP/Request.php';
$options = array();
serendipity_plugin_api::hook_event('backend_http_request', $options, 'spartacus');
$req = &new HTTP_Request($url, $options);
if (PEAR::isError($req->sendRequest()) || $req->getResponseCode() != '200') {
printf(PLUGIN_EVENT_SPARTACUS_FETCHERROR, $url);
echo '<br />';
if (file_exists($target) && filesize($target) > 0) {
$data = file_get_contents($target);
printf(PLUGIN_EVENT_SPARTACUS_FETCHED_BYTES_CACHE, strlen($data), $target);
echo '<br />';
}
} else {
// Fetch file
$data = $req->getResponseBody();
}
?>
Expected result:
----------------
I would expect the script to emit the notice, but still continue the logic flow.
Actual result:
--------------
Connection refused
Notice: Connection refused in /home/garvin/cvs/serendipity/trunk/bundled-libs/PEAR.php on line 848
Connection refused