From 0a1554e08bbd4f66c085355e014d24bf0878838b Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 16 Oct 2017 03:14:32 +0000 Subject: [PATCH] Special treatment for HTTP Code 416 --- include/network.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/network.php b/include/network.php index dad70f7e45..c705d4e78c 100644 --- a/include/network.php +++ b/include/network.php @@ -164,6 +164,15 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array()) { // if it throws any errors. $s = @curl_exec($ch); + $curl_info = @curl_getinfo($ch); + + // Special treatment for HTTP Code 416 + // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416 + if (($curl_info['http_code'] == 416) && ($range > 0)) { + @curl_setopt($ch, CURLOPT_RANGE, ''); + $s = @curl_exec($ch); + $curl_info = @curl_getinfo($ch); + } if (curl_errno($ch) !== CURLE_OK) { logger('fetch_url error fetching ' . $url . ': ' . curl_error($ch), LOGGER_NORMAL); @@ -172,10 +181,10 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array()) { $ret['errno'] = curl_errno($ch); $base = $s; - $curl_info = @curl_getinfo($ch); $ret['info'] = $curl_info; $http_code = $curl_info['http_code']; + logger('fetch_url ' . $url . ': ' . $http_code . " " . $s, LOGGER_DATA); $header = '';