|
@@ -39,18 +39,18 @@ class HttpUtils |
|
@@ -39,18 +39,18 @@ class HttpUtils |
|
39
|
* @return int
|
39
|
* @return int
|
|
40
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
40
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
|
41
|
*/
|
41
|
*/
|
|
42
|
- public static function get($url, $data, $headers = [])
|
42
|
+ public static function get($url, $data, $headers = [],$timeout=60)
|
|
43
|
{
|
43
|
{
|
|
44
|
LogUtils::info("HttpUtils-GET请求URL:" . $url);
|
44
|
LogUtils::info("HttpUtils-GET请求URL:" . $url);
|
|
45
|
- $response = Http::timeout(60)->withHeaders($headers)->get($url, $data);
|
45
|
+ $response = Http::timeout($timeout)->withHeaders($headers)->get($url, $data);
|
|
46
|
self::checkSuccess($response);
|
46
|
self::checkSuccess($response);
|
|
47
|
return $response->getBody()->getContents();
|
47
|
return $response->getBody()->getContents();
|
|
48
|
}
|
48
|
}
|
|
49
|
|
49
|
|
|
50
|
- public static function post($url, $data, $headers = [])
|
50
|
+ public static function post($url, $data, $headers = [],$timeout=60)
|
|
51
|
{
|
51
|
{
|
|
52
|
LogUtils::info("HttpUtils-POST请求URL:" . $url);
|
52
|
LogUtils::info("HttpUtils-POST请求URL:" . $url);
|
|
53
|
- $response = Http::timeout(60)->withHeaders($headers)->post($url, $data);
|
53
|
+ $response = Http::timeout($timeout)->withHeaders($headers)->post($url, $data);
|
|
54
|
self::checkSuccess($response);
|
54
|
self::checkSuccess($response);
|
|
55
|
return $response->getBody()->getContents();
|
55
|
return $response->getBody()->getContents();
|
|
56
|
}
|
56
|
}
|