reintroduce the old getRedirectUrl()
cc @mmn the new getRedirectUrl() didn't work with quitter.es, either from quitter.se or quitter.no it also looked like the HTTPClient-based function downloaded the whole file, instead of only the headers. (but i'm not sure)
This commit is contained in:
parent
a016241dea
commit
4677503011
|
@ -143,14 +143,19 @@ class ApiExternalUserShowAction extends ApiPrivateAuthAction
|
|||
/**
|
||||
* Get redirect(s) for an url
|
||||
*
|
||||
* @return mixed Location URL if redirect, null if no Location header (through HTTP_Request2_Response getHeader())
|
||||
*/
|
||||
function getRedirectUrl ($url) {
|
||||
$client = new HTTPClient();
|
||||
$response = $client->head($url);
|
||||
return $response->getHeader('Location'); // null if it isn't set
|
||||
stream_context_set_default(array(
|
||||
'http' => array(
|
||||
'method' => 'HEAD'
|
||||
)
|
||||
));
|
||||
$headers = get_headers($url, 1);
|
||||
if ($headers !== false && isset($headers['Location'])) {
|
||||
return $headers['Location'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user