更改client,增加设置header头
This commit is contained in:
parent
0d701a1167
commit
fde7194d8e
|
@ -63,7 +63,7 @@ class Client extends JsonRpc
|
||||||
* @throws RpcServerException
|
* @throws RpcServerException
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function call($name, $arguments)
|
public function call($name, $arguments, $header = [])
|
||||||
{
|
{
|
||||||
$payload = [
|
$payload = [
|
||||||
'jsonrpc' => '2.0',
|
'jsonrpc' => '2.0',
|
||||||
|
@ -71,7 +71,7 @@ class Client extends JsonRpc
|
||||||
'params' => $arguments,
|
'params' => $arguments,
|
||||||
'id' => $this->id(),
|
'id' => $this->id(),
|
||||||
];
|
];
|
||||||
return $this->post($payload);
|
return $this->post($payload, $header);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +90,7 @@ class Client extends JsonRpc
|
||||||
* @throws RpcServerException
|
* @throws RpcServerException
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function post($payload)
|
protected function post($payload, $header = [])
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$headers = [
|
$headers = [
|
||||||
|
@ -98,7 +98,7 @@ class Client extends JsonRpc
|
||||||
];
|
];
|
||||||
app('rpc.logger')->info("client_request", array_merge($this->server_config, $payload));
|
app('rpc.logger')->info("client_request", array_merge($this->server_config, $payload));
|
||||||
$resp = $this->http->request('POST', 'rpc/json-rpc-v2.json', [
|
$resp = $this->http->request('POST', 'rpc/json-rpc-v2.json', [
|
||||||
'headers' => $headers,
|
'headers' => array_merge($headers, $header),
|
||||||
'json' => $payload,
|
'json' => $payload,
|
||||||
]);
|
]);
|
||||||
} catch (ServerException $e) {
|
} catch (ServerException $e) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user