Use the upstream function to get effectiveUrl

This commit is contained in:
Mikael Nordfeldth 2016-01-13 14:00:05 +01:00
parent eceafb84de
commit e75472f460
6 changed files with 11 additions and 11 deletions

View File

@ -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;
}
}
}

View File

@ -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;
}
/**

View File

@ -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

View File

@ -70,7 +70,7 @@ class DiscoveryHints {
}
return self::hcardHints($response->getBody(),
$response->getUrl());
$response->getEffectiveUrl());
}
static function hcardHints($body, $url)

View File

@ -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);

View File

@ -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;