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

42 lines
540 B
PHP
Raw Normal View History

2020-11-16 01:12:06 +08:00
<?php
namespace HttpServer\Client;
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
/**
* @param $name
* @return IClient
*/
2020-11-16 19:00:03 +08:00
public static function NewRequest($name): IClient
2020-11-16 13:46:24 +08:00
{
if (Coroutine::getCid() > 0) {
return Client::NewRequest();
} else {
return Curl::NewRequest();
}
}
2020-11-16 19:00:03 +08:00
/**
* @return Http2
*/
public static function http2()
{
return Snowflake::app()->http2;
}
2020-11-16 13:46:24 +08:00
}