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

index 053c65c0d1a7f789bc54936f15778a0aced896cc..301d4c3a7add4286592ce6aa3acb9eb38bd9b539 100644 (file)
@@ -220,7 +220,7 @@ class HTTPClient implements IHTTPClient
                $urlResult = $this->resolver->resolveURL($url);
 
                if ($urlResult->didErrorOccur()) {
-                       throw new TransferException($urlResult->getErrorMessageString());
+                       throw new TransferException($urlResult->getErrorMessageString(), $urlResult->getHTTPStatusCode());
                }
 
                return $urlResult->getURL();
index 87168055321f4bc6291b1f3d92021286a8461fc1..0b51d6480e433d6b6fa7a3741096d14e84f28879 100644 (file)
@@ -21,6 +21,8 @@
 
 namespace Friendica\Network;
 
+use GuzzleHttp\Exception\TransferException;
+
 /**
  * Interface for calling HTTP requests and returning their responses
  */
@@ -124,7 +126,8 @@ interface IHTTPClient
         * @param string $url       A user-submitted URL
         *
         * @return string A canonical URL
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        *
+        * @throws TransferException In case there's an error during the resolving
         */
        public function finalUrl(string $url);
 }
index 8ab7066ea99e4bfc7ca56e28c9bd143527e83872..07fa04518a3bdcbc95c917d68b5d0fd7e5a3c1fe 100644 (file)
@@ -42,6 +42,7 @@ use Friendica\Util\ParseUrl;
 use Friendica\Util\Proxy;
 use Friendica\Util\Strings;
 use Friendica\Util\XML;
+use GuzzleHttp\Exception\TransferException;
 
 /**
  * This class contain functions to import feeds (RSS/RDF/Atom)
@@ -297,7 +298,11 @@ class Feed
 
                        $orig_plink = $item["plink"];
 
-                       $item["plink"] = DI::httpClient()->finalUrl($item["plink"]);
+                       try {
+                               $item["plink"] = DI::httpClient()->finalUrl($item["plink"]);
+                       } catch (TransferException $exception) {
+                               Logger::notice('Item URL couldn\'t get expanded', ['url' => $item["plink"], 'exception' => $exception]);
+                       }
 
                        $item["title"] = XML::getFirstNodeValue($xpath, 'atom:title/text()', $entry);