mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-09-01 08:15:57 +02:00
refactor (#3668)
This commit is contained in:
parent
cf7e3eea56
commit
e6aef73a02
15 changed files with 134 additions and 384 deletions
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue