Merge pull request 'Handle no response body, file_get_contents() failure in UrlHelper::fetch()' (#78) from wn/tt-rss:feature/handle-no-response-body into master
Reviewed-on: https://dev.tt-rss.org/fox/tt-rss/pulls/78
This commit is contained in:
commit
3b7174788d
|
@ -462,7 +462,11 @@ class UrlHelper {
|
|||
}
|
||||
|
||||
if (!$contents) {
|
||||
if (curl_errno($ch) === 0) {
|
||||
self::$fetch_last_error = 'Successful response, but no content was received.';
|
||||
} else {
|
||||
self::$fetch_last_error = curl_errno($ch) . " " . curl_error($ch);
|
||||
}
|
||||
curl_close($ch);
|
||||
return false;
|
||||
}
|
||||
|
@ -543,6 +547,11 @@ class UrlHelper {
|
|||
|
||||
$data = @file_get_contents($url, false, $context);
|
||||
|
||||
if ($data === false) {
|
||||
self::$fetch_last_error = "'file_get_contents' failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($http_response_header as $header) {
|
||||
if (strstr($header, ": ") !== false) {
|
||||
list ($key, $value) = explode(": ", $header);
|
||||
|
@ -578,6 +587,11 @@ class UrlHelper {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!$data) {
|
||||
self::$fetch_last_error = 'Successful response, but no content was received.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$is_gzipped = RSSUtils::is_gzipped($data);
|
||||
|
||||
if ($is_gzipped && $data) {
|
||||
|
|
Loading…
Reference in New Issue