add \Hyperf\GrpcClient\Request

This commit is contained in:
buexplain 2019-08-09 13:38:51 +08:00
parent 1678cf7018
commit 3dd49d2874
3 changed files with 25 additions and 4 deletions

View File

@ -17,7 +17,6 @@ use Hyperf\Grpc\Parser;
use Hyperf\Utils\ApplicationContext;
use Hyperf\Utils\ChannelPool;
use InvalidArgumentException;
use Swoole\Http2\Request;
/**
* @method int send(Request $request)
@ -84,7 +83,6 @@ class BaseClient
$deserialize
) {
$request = new Request();
$request->headers['content-type'] = 'application/grpc';
$request->method = 'POST';
$request->path = $method;
$request->data = Parser::serializeMessage($argument);

View File

@ -19,7 +19,6 @@ use InvalidArgumentException;
use RuntimeException;
use Swoole\Coroutine\Channel;
use Swoole\Coroutine\Http2\Client as SwooleHttp2Client;
use Swoole\Http2\Request;
class GrpcClient
{
@ -210,7 +209,6 @@ class GrpcClient
public function openStream(string $path, string $data = null, string $method = 'POST'): int
{
$request = new Request();
$request->headers['content-type'] = 'application/grpc';
$request->method = $method;
$request->path = $path;
if ($data) {

View File

@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
*/
namespace Hyperf\GrpcClient;
use Swoole\Http2\Request as BaseRequest;
class Request extends BaseRequest
{
const CONTENT_TYPE = 'application/grpc';
public function __construct()
{
$this->headers['content-type'] = self::CONTENT_TYPE;
}
}