Skip to content

Commit 983ef5e

Browse files
committed
feature: get request response on header
1 parent 3e0822c commit 983ef5e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Http/Client/HttpClient.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ final class HttpClient
2929

3030
private $_method;
3131

32+
private $_responseHeaders = [];
33+
3234
private $_options = [];
3335

3436
/**
@@ -235,6 +237,8 @@ public function request($url, $type, $data, $headers = null, $options = null)
235237

236238
$decodedData = JSON::decode($responseBody);
237239

240+
$this->_responseHeaders = wp_remote_retrieve_headers($requestResponse);
241+
238242
$response = empty($decodedData) ? $responseBody : $decodedData;
239243

240244
if (!empty($responseCode)) {
@@ -248,6 +252,11 @@ public function request($url, $type, $data, $headers = null, $options = null)
248252
return $response;
249253
}
250254

255+
public function getResponseHeaders()
256+
{
257+
return $this->_responseHeaders;
258+
}
259+
251260
private function setDefault(array $config)
252261
{
253262
if (isset($config['base_uri'])) {

0 commit comments

Comments
 (0)