Merge pull request #3793 from annando/parse-fix
Special treatment for HTTP Code 416
This commit is contained in:
commit
3fd0210681
1 changed files with 10 additions and 1 deletions
|
@ -164,6 +164,15 @@ function z_fetch_url($url, $binary = false, &$redirects = 0, $opts = array()) {
|
||||||
// if it throws any errors.
|
// if it throws any errors.
|
||||||
|
|
||||||
$s = @curl_exec($ch);
|
$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) {
|
if (curl_errno($ch) !== CURLE_OK) {
|
||||||
logger('fetch_url error fetching ' . $url . ': ' . curl_error($ch), LOGGER_NORMAL);
|
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);
|
$ret['errno'] = curl_errno($ch);
|
||||||
|
|
||||||
$base = $s;
|
$base = $s;
|
||||||
$curl_info = @curl_getinfo($ch);
|
|
||||||
$ret['info'] = $curl_info;
|
$ret['info'] = $curl_info;
|
||||||
|
|
||||||
$http_code = $curl_info['http_code'];
|
$http_code = $curl_info['http_code'];
|
||||||
|
|
||||||
logger('fetch_url ' . $url . ': ' . $http_code . " " . $s, LOGGER_DATA);
|
logger('fetch_url ' . $url . ': ' . $http_code . " " . $s, LOGGER_DATA);
|
||||||
$header = '';
|
$header = '';
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue