[contents] Return error if the server responded with any code other than 200

This commit is contained in:
logmanoriginal 2018-09-26 19:16:02 +02:00
parent fcc9f9fd61
commit 13bd7fe21b

View file

@ -32,19 +32,26 @@ function getContents($url, $header = array(), $opts = array()){
debugMessage('Cant\'t download ' . $url . ' cUrl error: ' . $curlError . ' (' . $curlErrno . ')'); debugMessage('Cant\'t download ' . $url . ' cUrl error: ' . $curlError . ' (' . $curlErrno . ')');
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$errorCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$header = substr($data, 0, $headerSize); $header = substr($data, 0, $headerSize);
$headers = parseResponseHeader($header); $headers = parseResponseHeader($header);
$finalHeader = end($headers); $finalHeader = end($headers);
if(array_key_exists('http_code', $finalHeader) if($errorCode !== 200) {
&& strpos($finalHeader['http_code'], '200') === false
&& array_key_exists('Server', $finalHeader) if(array_key_exists('Server', $finalHeader) && strpos($finalHeader['Server'], 'cloudflare') !== false) {
&& strpos($finalHeader['Server'], 'cloudflare') !== false) { returnServerError(<<< EOD
returnServerError(<<< EOD The server responded with a Cloudflare challenge, which is not supported by RSS-Bridge!
The server responded with a Cloudflare challenge, which is not supported by RSS-Bridge!<br>
If this error persists longer than a week, please consider opening an issue on GitHub! If this error persists longer than a week, please consider opening an issue on GitHub!
EOD EOD
); );
}
returnError(<<<EOD
The requested resouce cannot be found!
Please make sure your input parameters are correct!
EOD
, $errorCode);
} }
curl_close($ch); curl_close($ch);