diff --git a/lib/httpclient.php b/lib/httpclient.php index 5fe0e9f329..4c7a4a9c64 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -27,12 +27,7 @@ * @link http://status.net/ */ -if (!defined('GNUSOCIAL')) { - exit(1); -} - -require_once 'HTTP/Request2.php'; -require_once 'HTTP/Request2/Response.php'; +if (!defined('GNUSOCIAL')) { exit(1); } /** * Useful structure for HTTP responses @@ -332,7 +327,7 @@ class HTTPClient extends HTTP_Request2 do { try { $response = parent::send(); - } catch (HTTP_Request2_Exception $e) { + } catch (Exception $e) { $this->log(LOG_ERR, $e->getMessage()); throw $e; } @@ -355,6 +350,8 @@ class HTTPClient extends HTTP_Request2 continue; } catch (HTTP_Request2_Exception $e) { common_log(LOG_ERR, __CLASS__ . ": Invalid $code redirect from $url to $target"); + } catch (NoHttpResponseException $e) { + common_log(LOG_ERR, __CLASS__ . ": {$e->getMessage()}"); } } else { $reason = $response->getReasonPhrase(); diff --git a/plugins/Diaspora/DiasporaPlugin.php b/plugins/Diaspora/DiasporaPlugin.php index 376ad098b2..e80153e7ad 100644 --- a/plugins/Diaspora/DiasporaPlugin.php +++ b/plugins/Diaspora/DiasporaPlugin.php @@ -240,7 +240,7 @@ class DiasporaPlugin extends Plugin $client = new HTTPClient(); $client->setBody('xml=' . Magicsig::base64_url_encode($envxml)); $response = $client->post($endpoint_uri, $headers); - } catch (HTTP_Request2_Exception $e) { + } catch (Exception $e) { common_log(LOG_ERR, "Diaspora-flavoured Salmon post to $endpoint_uri failed: " . $e->getMessage()); return false; } diff --git a/plugins/GeoURL/GeoURLPlugin.php b/plugins/GeoURL/GeoURLPlugin.php index 0e779a4fe8..a64ac7f4fd 100644 --- a/plugins/GeoURL/GeoURLPlugin.php +++ b/plugins/GeoURL/GeoURLPlugin.php @@ -107,7 +107,7 @@ class GeoURLPlugin extends Plugin $request->post($this->ping, null, array('p' => $url)); - } catch (HTTP_Request2_Exception $e) { + } catch (Exception $e) { common_log(LOG_WARNING, "GeoURL.org ping failed for '$url' ($this->ping)"); } diff --git a/plugins/Linkback/LinkbackPlugin.php b/plugins/Linkback/LinkbackPlugin.php index 941e7c4c4b..dbc8818843 100644 --- a/plugins/Linkback/LinkbackPlugin.php +++ b/plugins/Linkback/LinkbackPlugin.php @@ -182,9 +182,8 @@ class LinkbackPlugin extends Plugin common_log(LOG_WARNING, "Webmention request failed for '$url' ($endpoint)"); } - } catch (HTTP_Request2_Exception $e) { - common_log(LOG_WARNING, - "Webmention request failed for '$url' ($endpoint)"); + } catch (Exception $e) { + common_log(LOG_WARNING, "Webmention request failed for '{$url}' ({$endpoint}): {$e->getMessage()}"); } } @@ -224,9 +223,8 @@ class LinkbackPlugin extends Plugin "Pingback success for '$url' ($endpoint): ". "'$response'"); } - } catch (HTTP_Request2_Exception $e) { - common_log(LOG_WARNING, - "Pingback request failed for '$url' ($endpoint)"); + } catch (Exception $e) { + common_log(LOG_WARNING, "Pingback request failed for '{$url}' ({$endpoint}): {$e->getMessage()}"); } } diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php index 7c509f0641..af458fb40c 100644 --- a/plugins/OStatus/OStatusPlugin.php +++ b/plugins/OStatus/OStatusPlugin.php @@ -1404,7 +1404,7 @@ class OStatusPlugin extends Plugin $client = new HTTPClient(); $client->setBody($envxml); $response = $client->post($endpoint_uri, $headers); - } catch (HTTP_Request2_Exception $e) { + } catch (Exception $e) { common_log(LOG_ERR, "Salmon post to $endpoint_uri failed: " . $e->getMessage()); return false; } diff --git a/plugins/OStatus/lib/feeddiscovery.php b/plugins/OStatus/lib/feeddiscovery.php index 84933e196b..02c3ce0212 100644 --- a/plugins/OStatus/lib/feeddiscovery.php +++ b/plugins/OStatus/lib/feeddiscovery.php @@ -118,7 +118,7 @@ class FeedDiscovery try { $client = new HTTPClient(); $response = $client->get($url); - } catch (HTTP_Request2_Exception $e) { + } catch (Exception $e) { common_log(LOG_ERR, __METHOD__ . " Failure for $url - " . $e->getMessage()); throw new FeedSubBadURLException($e->getMessage()); } diff --git a/plugins/RSSCloud/lib/rsscloudnotifier.php b/plugins/RSSCloud/lib/rsscloudnotifier.php index 6efe419770..21d9597302 100644 --- a/plugins/RSSCloud/lib/rsscloudnotifier.php +++ b/plugins/RSSCloud/lib/rsscloudnotifier.php @@ -63,7 +63,7 @@ class RSSCloudNotifier try { $client = new HTTPClient(); $response = $client->get($url); - } catch (HTTP_Request2_Exception $e) { + } catch (Exception $e) { common_log(LOG_INFO, 'RSSCloud plugin - failure testing notify handler ' . $endpoint . ' - ' . $e->getMessage()); @@ -118,7 +118,7 @@ class RSSCloudNotifier try { $client = new HTTPClient(); $response = $client->post($endpoint, $headers, $postdata); - } catch (HTTP_Request2_Exception $e) { + } catch (Exception $e) { common_log(LOG_INFO, 'RSSCloud plugin - failure notifying ' . $endpoint . ' that feed ' . $feed . ' has changed: ' . $e->getMessage()); diff --git a/scripts/importtwitteratom.php b/scripts/importtwitteratom.php index a29526f27e..1a08dd7488 100755 --- a/scripts/importtwitteratom.php +++ b/scripts/importtwitteratom.php @@ -108,7 +108,7 @@ function getTweetHtml($url) try { $client = new HTTPClient(); $response = $client->get($url); - } catch (HTTP_Request2_Exception $e) { + } catch (Exception $e) { print "ERROR: HTTP response " . $e->getMessage() . "\n"; return false; }