[contents] Return error if the server responded with any code other than 200
This commit is contained in:
parent
fcc9f9fd61
commit
13bd7fe21b
1 changed files with 14 additions and 7 deletions
|
@ -32,21 +32,28 @@ 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!<br>
|
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!
|
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);
|
||||||
return substr($data, $headerSize);
|
return substr($data, $headerSize);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue