mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-06 08:37:30 +02:00
refactor (#3668)
This commit is contained in:
17
lib/http.php
17
lib/http.php
@@ -6,6 +6,21 @@ class HttpException extends \Exception
|
||||
|
||||
final class CloudFlareException extends HttpException
|
||||
{
|
||||
public static function isCloudFlareResponse(Response $response): bool
|
||||
{
|
||||
$cloudflareTitles = [
|
||||
'<title>Just a moment...',
|
||||
'<title>Please Wait...',
|
||||
'<title>Attention Required!',
|
||||
'<title>Security | Glassdoor',
|
||||
];
|
||||
foreach ($cloudflareTitles as $cloudflareTitle) {
|
||||
if (str_contains($response->getBody(), $cloudflareTitle)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
interface HttpClient
|
||||
@@ -119,7 +134,7 @@ final class CurlHttpClient implements HttpClient
|
||||
}
|
||||
}
|
||||
|
||||
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$statusCode = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
|
||||
curl_close($ch);
|
||||
return new Response($data, $statusCode, $responseHeaders);
|
||||
}
|
||||
|
Reference in New Issue
Block a user