改名
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Client;
|
||||
namespace HttpServer\Client\Help;
|
||||
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
@@ -27,7 +27,7 @@ class Client extends ClientAbstracts
|
||||
* @return array|string|Result
|
||||
* @throws Exception
|
||||
*/
|
||||
public function request(string $method, $path, $params = []): array|string|Result
|
||||
public function request(string $method, $path, array $params = []): array|string|Result
|
||||
{
|
||||
return $this->setMethod($method)
|
||||
->coroutine(
|
||||
@@ -44,7 +44,7 @@ class Client extends ClientAbstracts
|
||||
* @throws Exception
|
||||
* 使用swoole协程方式请求
|
||||
*/
|
||||
private function coroutine($url, $data = []): array|string|Result
|
||||
private function coroutine($url, array $data = []): array|string|Result
|
||||
{
|
||||
try {
|
||||
$client = $this->generate_client($data, ...$url);
|
||||
@@ -99,7 +99,7 @@ class Client extends ClientAbstracts
|
||||
|
||||
|
||||
/**
|
||||
* @param $client
|
||||
* @param SClient $client
|
||||
* @param $path
|
||||
* @param $data
|
||||
* @return string
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace HttpServer\Client;
|
||||
namespace HttpServer\Client\Help;
|
||||
|
||||
|
||||
use Closure;
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Client;
|
||||
namespace HttpServer\Client\Help;
|
||||
|
||||
|
||||
use Exception;
|
||||
@@ -22,7 +22,7 @@ class Curl extends ClientAbstracts
|
||||
* @return Result|array|string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function request($method, $path, $params = []): Result|array|string
|
||||
public function request($method, $path, array $params = []): Result|array|string
|
||||
{
|
||||
if ($method == self::GET) {
|
||||
$path = $this->joinGetParams($path, $params);
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace HttpServer\Client;
|
||||
namespace HttpServer\Client\Help;
|
||||
|
||||
|
||||
use Closure;
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace HttpServer\Client;
|
||||
namespace HttpServer\Client\Help;
|
||||
|
||||
use Exception;
|
||||
|
||||
@@ -6,11 +6,14 @@ namespace HttpServer\Client;
|
||||
|
||||
use Exception;
|
||||
use HttpServer\Http\Context;
|
||||
use Server\Events\OnAfterRequest;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Channel;
|
||||
use Snowflake\Core\Json;
|
||||
use Snowflake\Core\Xml;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Events\EventProvider;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Coroutine\Http2\Client as H2Client;
|
||||
use Swoole\Http2\Request;
|
||||
use Swoole\Http2\Response;
|
||||
@@ -60,12 +63,12 @@ class Http2 extends Component
|
||||
|
||||
|
||||
/**
|
||||
* @param bool $isRecv
|
||||
* @param bool $isRev
|
||||
* @return Http2
|
||||
*/
|
||||
public function setIsRecv(bool $isRecv): static
|
||||
public function setIsRev(bool $isRev): static
|
||||
{
|
||||
Context::setContext('http2isRecv', $isRecv);
|
||||
Context::setContext('http2isRev', $isRev);
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -204,10 +207,10 @@ class Http2 extends Component
|
||||
{
|
||||
$client = $this->getClient($domain, $ssl, $timeout);
|
||||
$client->send($request);
|
||||
if (Context::getContext('http2isRecv') === false) {
|
||||
if (Context::getContext('http2isRev') === false) {
|
||||
return null;
|
||||
}
|
||||
return $this->recv($client);
|
||||
return $this->rev($client);
|
||||
}
|
||||
|
||||
|
||||
@@ -216,7 +219,7 @@ class Http2 extends Component
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
private function recv($client): mixed
|
||||
private function rev($client): mixed
|
||||
{
|
||||
/** @var Response $response */
|
||||
if (!Context::hasContext('http2timeout')) {
|
||||
@@ -246,7 +249,7 @@ class Http2 extends Component
|
||||
* @return mixed
|
||||
* @throws Exception
|
||||
*/
|
||||
public function put($domain, $path, $params = [], $timeout = -1): Result
|
||||
public function put($domain, $path, array $params = [], int $timeout = -1): Result
|
||||
{
|
||||
$request = $this->dispatch($domain, $path, 'PUT', $params, $timeout);
|
||||
|
||||
|
||||
@@ -5,11 +5,12 @@ namespace HttpServer\Client;
|
||||
|
||||
|
||||
use Exception;
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Coroutine;
|
||||
|
||||
use HttpServer\Client\Help\IClient;
|
||||
use HttpServer\Client\Help\Client;
|
||||
use HttpServer\Client\Help\Curl;
|
||||
|
||||
/**
|
||||
* Class ClientDriver
|
||||
|
||||
Reference in New Issue
Block a user