This commit is contained in:
Dag 2023-09-20 02:45:48 +02:00 committed by GitHub
parent cf7e3eea56
commit e6aef73a02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 134 additions and 384 deletions

View file

@ -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);
}