@@ -29,10 +29,10 @@ public static function fake(array $queue): void
29
29
self ::$ queue = $ queue ;
30
30
}
31
31
32
- public static function check (string $ url , ?string $ userAgent = null ): CheckData
32
+ public static function check (string $ url , ?string $ userAgent = null , ? int $ connectTimeout = null , ? int $ timeout = null ): CheckData
33
33
{
34
34
try {
35
- $ response = (new self ())->getResponse ($ url , $ userAgent );
35
+ $ response = (new self ())->getResponse ($ url , $ userAgent, $ connectTimeout , $ timeout );
36
36
37
37
if (!$ response instanceof ResponseInterface) {
38
38
return new CheckData (
@@ -81,16 +81,16 @@ private function getConfig(): array
81
81
/**
82
82
* @throws GuzzleException
83
83
*/
84
- private function getResponse (string $ url , ?string $ userAgent = null ): ?ResponseInterface
84
+ private function getResponse (string $ url , ?string $ userAgent = null , ? int $ connectTimeout = null , ? int $ timeout = null ): ?ResponseInterface
85
85
{
86
86
$ response = null ;
87
87
88
88
$ client = (new Client ($ this ->getConfig ()));
89
89
90
90
try {
91
91
$ client ->get ($ url , [
92
- 'connect_timeout ' => 2 ,
93
- 'timeout ' => 5 ,
92
+ 'connect_timeout ' => $ connectTimeout ?? 2 ,
93
+ 'timeout ' => $ timeout ?? 5 ,
94
94
'headers ' => [
95
95
'User-Agent ' => implode (' ' , array_filter ([
96
96
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ' ,
0 commit comments