Files
kiri-core/HttpServer/Client/HttpClient.php
T

40 lines
567 B
PHP
Raw Normal View History

2020-11-16 01:12:06 +08:00
<?php
namespace HttpServer\Client;
2021-05-06 10:49:25 +08:00
use Exception;
use JetBrains\PhpStorm\Pure;
2020-11-16 01:12:06 +08:00
use Snowflake\Abstracts\Component;
2020-11-16 19:00:03 +08:00
use Snowflake\Snowflake;
2020-11-16 13:46:24 +08:00
use Swoole\Coroutine;
2020-11-16 01:12:06 +08:00
/**
* Class ClientDriver
* @package HttpServer\Client
*/
2020-11-16 19:00:03 +08:00
class HttpClient extends Component
2020-11-16 01:12:06 +08:00
{
2020-11-16 13:46:24 +08:00
/**
* @return IClient
*/
2020-11-17 10:36:51 +08:00
public static function NewRequest(): IClient
2020-11-16 13:46:24 +08:00
{
2021-05-06 10:49:25 +08:00
return Coroutine::getCid() > -1 ? Client::NewRequest() : Curl::NewRequest();
2020-11-16 13:46:24 +08:00
}
2020-11-16 19:00:03 +08:00
/**
* @return Http2
2021-05-06 10:49:25 +08:00
* @throws Exception
2020-11-16 19:00:03 +08:00
*/
2020-12-17 14:12:44 +08:00
public static function http2(): Http2
2020-11-16 19:00:03 +08:00
{
2021-05-06 10:49:25 +08:00
return Snowflake::app()->get('http2');
2020-11-16 19:00:03 +08:00
}
2020-11-16 13:46:24 +08:00
}