# HG changeset patch # User Tom Fredrik Blenning Klaussen # Date 1514482856 -3600 # Node ID 111770d32c2eb737fc0693723709ca110c7c3cc7 # Parent df158368051eead6fa3d518f8df88eb42fc38b8a Workaround for pecl_http not working with PHP7 diff -r df158368051e -r 111770d32c2e Http.inc --- a/Http.inc Thu Dec 28 18:36:45 2017 +0100 +++ b/Http.inc Thu Dec 28 18:40:56 2017 +0100 @@ -97,13 +97,27 @@ */ static function getHeaders($url, $timeout = 1) { - $response = @http_head($url, array("timeout" => $timeout), $info); - - if (array_key_exists('error', $info) && $info['error']) { - throw new RequestException($info); + //Workaround when getHeaders doesn't work + if (false) { + $response = http_head($url, array("timeout" => $timeout), $info); + if (array_key_exists('error', $info) && $info['error']) { + throw new RequestException($info); + } + return self::headersToArray($response); + } + elseif (true) { + $rp = get_headers($url); + $response=array('' => array_shift ($rp)); + foreach($rp as $kv) { + $tmp=array_map('trim', explode(':', $kv, 2)); + $response[$tmp[0]]=$tmp[1]; + } + return $response; + } + else { + return array('' => 'HTTP/1.1 200 OK'); } - return self::headersToArray($response); } /**