From 13bd7fe21b1fa3e3c9b5cbac2264873d3c9527dd Mon Sep 17 00:00:00 2001 From: logmanoriginal Date: Wed, 26 Sep 2018 19:16:02 +0200 Subject: [PATCH] [contents] Return error if the server responded with any code other than 200 --- lib/contents.php | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/contents.php b/lib/contents.php index ca0ef8bc..2acc7fc5 100644 --- a/lib/contents.php +++ b/lib/contents.php @@ -32,19 +32,26 @@ function getContents($url, $header = array(), $opts = array()){ debugMessage('Cant\'t download ' . $url . ' cUrl error: ' . $curlError . ' (' . $curlErrno . ')'); $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); + $errorCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $header = substr($data, 0, $headerSize); $headers = parseResponseHeader($header); $finalHeader = end($headers); - if(array_key_exists('http_code', $finalHeader) - && strpos($finalHeader['http_code'], '200') === false - && array_key_exists('Server', $finalHeader) - && strpos($finalHeader['Server'], 'cloudflare') !== false) { - returnServerError(<<< EOD -The server responded with a Cloudflare challenge, which is not supported by RSS-Bridge!
+ if($errorCode !== 200) { + + if(array_key_exists('Server', $finalHeader) && strpos($finalHeader['Server'], 'cloudflare') !== false) { + returnServerError(<<< EOD +The server responded with a Cloudflare challenge, which is not supported by RSS-Bridge! If this error persists longer than a week, please consider opening an issue on GitHub! EOD - ); + ); + } + + returnError(<<