From: Mikael Nordfeldth Date: Wed, 13 Jan 2016 13:00:05 +0000 (+0100) Subject: Use the upstream function to get effectiveUrl X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e75472f4604c83e3c0a35acf18e0f4b9ee216980;p=quix0rs-gnu-social.git Use the upstream function to get effectiveUrl --- diff --git a/classes/File_redirection.php b/classes/File_redirection.php index 03df3de1b1..93cc640d34 100644 --- a/classes/File_redirection.php +++ b/classes/File_redirection.php @@ -127,14 +127,14 @@ class File_redirection extends Managed_DataObject return $short_url; } - if ($response->getRedirectCount() && File::isProtected($response->getUrl())) { + if ($response->getRedirectCount() && File::isProtected($response->getEffectiveUrl())) { // Bump back up the redirect chain until we find a non-protected URL return self::lookupWhere($short_url, $response->getRedirectCount() - 1, true); } $ret = array('code' => $response->getStatus() , 'redirects' => $response->getRedirectCount() - , 'url' => $response->getUrl()); + , 'url' => $response->getEffectiveUrl()); $type = $response->getHeader('Content-Type'); if ($type) $ret['type'] = $type; @@ -397,4 +397,4 @@ class File_redirection extends Managed_DataObject return $this->file; } -} \ No newline at end of file +} diff --git a/lib/httpclient.php b/lib/httpclient.php index dce8e821ff..98e5d0426b 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -75,12 +75,12 @@ class GNUsocial_HTTPResponse extends HTTP_Request2_Response } /** - * Gets the final target URL, after any redirects have been followed. + * Gets the target URL, before any redirects. Use getEffectiveUrl() for final target. * @return string URL */ function getUrl() { - return $this->effectiveUrl; + return $this->url; } /** diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index d36cbe21d6..e3802ea94c 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -632,7 +632,7 @@ class Ostatus_profile extends Managed_DataObject // Check if we have a non-canonical URL - $finalUrl = $response->getUrl(); + $finalUrl = $response->getEffectiveUrl(); if ($finalUrl != $profile_url) { @@ -649,7 +649,7 @@ class Ostatus_profile extends Managed_DataObject preg_replace('/\s*;.*$/', '', $response->getHeader('Content-Type')), array('application/rss+xml', 'application/atom+xml', 'application/xml', 'text/xml')) ) { - $hints['feedurl'] = $response->getUrl(); + $hints['feedurl'] = $response->getEffectiveUrl(); } else { // Try to get some hCard data diff --git a/plugins/OStatus/lib/discoveryhints.php b/plugins/OStatus/lib/discoveryhints.php index 2a1309d33f..d95bd8e78f 100644 --- a/plugins/OStatus/lib/discoveryhints.php +++ b/plugins/OStatus/lib/discoveryhints.php @@ -70,7 +70,7 @@ class DiscoveryHints { } return self::hcardHints($response->getBody(), - $response->getUrl()); + $response->getEffectiveUrl()); } static function hcardHints($body, $url) diff --git a/plugins/OStatus/lib/feeddiscovery.php b/plugins/OStatus/lib/feeddiscovery.php index e9c710bebd..84933e196b 100644 --- a/plugins/OStatus/lib/feeddiscovery.php +++ b/plugins/OStatus/lib/feeddiscovery.php @@ -127,7 +127,7 @@ class FeedDiscovery $type = $response->getHeader('Content-Type'); $isHtml = preg_match('!^(text/html|application/xhtml\+xml)!i', $type); if ($isHtml) { - $target = $this->discoverFromHTML($response->getUrl(), $response->getBody()); + $target = $this->discoverFromHTML($response->getEffectiveUrl(), $response->getBody()); if (!$target) { throw new FeedSubNoFeedException($url); } @@ -149,7 +149,7 @@ class FeedDiscovery throw new FeedSubBadResponseException($response->getStatus()); } - $sourceurl = $response->getUrl(); + $sourceurl = $response->getEffectiveUrl(); $body = $response->getBody(); if (!$body) { throw new FeedSubEmptyException($sourceurl); diff --git a/plugins/OStatus/scripts/update_ostatus_profiles.php b/plugins/OStatus/scripts/update_ostatus_profiles.php index 3f54c83cda..45ee856264 100755 --- a/plugins/OStatus/scripts/update_ostatus_profiles.php +++ b/plugins/OStatus/scripts/update_ostatus_profiles.php @@ -74,7 +74,7 @@ class LooseOstatusProfile extends Ostatus_profile // Check if we have a non-canonical URL - $finalUrl = $response->getUrl(); + $finalUrl = $response->getEffectiveUrl(); if ($finalUrl != $profile_url) { $hints['profileurl'] = $finalUrl;