From fde7194d8e60a805692cec22c1e7bf9465f8c258 Mon Sep 17 00:00:00 2001 From: chujiu Date: Mon, 11 Mar 2019 15:04:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9client,=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AEheader=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Client.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Client.php b/src/Client.php index 7dddfaf..d7333cc 100644 --- a/src/Client.php +++ b/src/Client.php @@ -63,7 +63,7 @@ class Client extends JsonRpc * @throws RpcServerException * @return array */ - public function call($name, $arguments) + public function call($name, $arguments, $header = []) { $payload = [ 'jsonrpc' => '2.0', @@ -71,7 +71,7 @@ class Client extends JsonRpc 'params' => $arguments, 'id' => $this->id(), ]; - return $this->post($payload); + return $this->post($payload, $header); } /** @@ -90,7 +90,7 @@ class Client extends JsonRpc * @throws RpcServerException * @return array */ - protected function post($payload) + protected function post($payload, $header = []) { try { $headers = [ @@ -98,7 +98,7 @@ class Client extends JsonRpc ]; app('rpc.logger')->info("client_request", array_merge($this->server_config, $payload)); $resp = $this->http->request('POST', 'rpc/json-rpc-v2.json', [ - 'headers' => $headers, + 'headers' => array_merge($headers, $header), 'json' => $payload, ]); } catch (ServerException $e) {