From 46775030118cf95a22b75bda718e6a53a5f4a9ee Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Tue, 2 Jun 2015 09:13:21 +0200 Subject: [PATCH] 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) --- actions/apiexternalusershow.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/actions/apiexternalusershow.php b/actions/apiexternalusershow.php index 515aad2..36f1cca 100644 --- a/actions/apiexternalusershow.php +++ b/actions/apiexternalusershow.php @@ -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; } - }