Skip to content

Commit 97f20c1

Browse files
committed
Store the request info before closing the request, this allows accessing any curl_getinfo info data from the client.
1 parent 00c728f commit 97f20c1

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/Kobas/APIClient/Client.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class Client
4646
protected $curl_options;
4747

4848

49+
protected $request_info;
50+
51+
4952
/**
5053
* Client constructor.
5154
*
@@ -185,6 +188,7 @@ protected function call($http_method, $route, array $params = array(), array $he
185188
throw new CurlException($this->request->getErrorMessage(), $this->request->getErrorNumber());
186189
}
187190

191+
$this->request_info = $this->request->getAllInfo();
188192
$last_response = $this->request->getInfo(CURLINFO_HTTP_CODE);
189193

190194
$this->request->close();
@@ -240,4 +244,12 @@ public function delete($route, array $params = array(), array $headers = array()
240244
{
241245
return $this->call('DELETE', $route, $params, $headers);
242246
}
247+
248+
/**
249+
* @return array|false
250+
*/
251+
public function getRequestInfo()
252+
{
253+
return $this->request_info;
254+
}
243255
}

src/Kobas/APIClient/Request/Curl.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ public function getInfo($name)
7272
return curl_getinfo($this->handle, $name);
7373
}
7474

75+
/**
76+
* @return array|false
77+
*/
78+
public function getAllInfo()
79+
{
80+
return curl_getinfo($this->handle);
81+
}
82+
7583
/**
7684
* @return int|mixed
7785
*/

0 commit comments

Comments
 (0)