Skip to content

Commit 2419aa3

Browse files
committed
Allows passing an optional array of cURL headers to the client constructor, headers passed directly to call() will still take precedence.
1 parent b5d9249 commit 2419aa3

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/Kobas/Client.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,25 @@ class Client
3939
*/
4040
protected $request;
4141

42+
/**
43+
* @var array
44+
*/
45+
protected $headers;
46+
4247
/**
4348
* Client constructor.
4449
* @param Signer $signer
4550
* @param HttpRequest|null $request
51+
* @param array $headers
4652
*/
47-
public function __construct(Signer $signer, HttpRequest $request = null)
53+
public function __construct(Signer $signer, HttpRequest $request = null, $headers = [])
4854
{
4955
$this->signer = $signer;
5056
if ($request == null) {
5157
$request = new Curl();
5258
}
5359
$this->request = $request;
60+
$this->headers = $headers;
5461
}
5562

5663
/**
@@ -151,6 +158,8 @@ protected function call($http_method, $route, array $params = array(), array $he
151158
$this->request->setOption(CURLOPT_SSL_VERIFYPEER, false);
152159
}
153160

161+
$headers = array_merge($this->headers, $headers);
162+
154163
$headers['Content-Type'] = 'application/json';
155164

156165
switch ($http_method) {

0 commit comments

Comments
 (0)