]> git.mxchange.org Git - friendica-addons.git/commitdiff
Catch TransferExceptions for HTTPClient::finalUrl() in case the headers are empty
authorPhilipp <admin@philipp.info>
Sun, 29 Aug 2021 11:37:07 +0000 (13:37 +0200)
committerPhilipp <admin@philipp.info>
Sun, 29 Aug 2021 11:37:07 +0000 (13:37 +0200)
statusnet/statusnet.php

index 6c7aec92f82e2cc17f04f202a504d6ca3c9a0680..cd3385434c03e2a49914be1eaffadb60903bb37a 100644 (file)
@@ -58,6 +58,7 @@ use Friendica\Model\User;
 use Friendica\Protocol\Activity;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Strings;
+use GuzzleHttp\Exception\TransferException;
 
 function statusnet_install()
 {
@@ -1426,7 +1427,12 @@ function statusnet_convertmsg(App $a, $body)
 
                        Logger::log("statusnet_convertmsg: expanding url " . $match[1], Logger::DEBUG);
 
-                       $expanded_url = DI::httpClient()->finalUrl($match[1]);
+                       try {
+                               $expanded_url = DI::httpClient()->finalUrl($match[1]);
+                       } catch (TransferException $exception) {
+                               Logger::notice('statusnet_convertmsg: Couldn\'t get final URL.', ['url' => $match[2], 'exception' => $exception]);
+                               $expanded_url = $match[2];
+                       }
 
                        Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, Logger::DEBUG);