summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-09-20 17:27:04 +0300
committerAndrew Dolgov <[email protected]>2020-09-20 17:27:04 +0300
commitd2867d887a6b8baa1ed3cc04af0a5f42926c45e9 (patch)
tree5338e694323d54af01577a063c32dcbcaefb63e0 /include
parent05ef9aac2feedae92a9df88779d1e640294a90d8 (diff)
resolve_redirects: only use three argument version of get_headers() on php 7.1+
Diffstat (limited to 'include')
-rw-r--r--include/functions.php39
1 files changed, 22 insertions, 17 deletions
diff --git a/include/functions.php b/include/functions.php
index 0a02ff0d5..136bccdf6 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -2008,23 +2008,28 @@
if ($nest > 10)
return false;
- $context_options = array(
- 'http' => array(
- 'header' => array(
- 'Connection: close'
- ),
- 'method' => 'HEAD',
- 'timeout' => $timeout,
- 'protocol_version'=> 1.1)
- );
-
- if (defined('_HTTP_PROXY')) {
- $context_options['http']['request_fulluri'] = true;
- $context_options['http']['proxy'] = _HTTP_PROXY;
- }
-
- $context = stream_context_create($context_options);
- $headers = get_headers($url, 0, $context);
+ if (version_compare(PHP_VERSION, '7.1.0', '>=')) {
+ $context = stream_context_create($context_options);
+
+ $context_options = array(
+ 'http' => array(
+ 'header' => array(
+ 'Connection: close'
+ ),
+ 'method' => 'HEAD',
+ 'timeout' => $timeout,
+ 'protocol_version'=> 1.1)
+ );
+
+ if (defined('_HTTP_PROXY')) {
+ $context_options['http']['request_fulluri'] = true;
+ $context_options['http']['proxy'] = _HTTP_PROXY;
+ }
+
+ $headers = get_headers($url, 0, $context);
+ } else {
+ $headers = get_headers($url, 0);
+ }
if (is_array($headers)) {
$headers = array_reverse($headers); // last one is the correct one