Skip to content

Commit ff05dd3

Browse files
authored
Merge pull request #31 from CristalTeam/feature/response_headers
Allow to fetch response headers from Transport
2 parents 945137e + 218bb8c commit ff05dd3

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

src/Bridges/BarryvdhLaravelDebugbar/DebugbarTransportDecorator.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,9 @@ public static function formatDuration($seconds)
185185

186186
return round($seconds, 2) . 's';
187187
}
188+
189+
public function getResponseHeaders(): array
190+
{
191+
$this->transport->getResponseHeaders();
192+
}
188193
}

src/Transports/NullTransport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ public function request($endpoint, array $data = [], $method = 'get')
3131
{
3232
return [];
3333
}
34+
35+
public function getResponseHeaders(): array
36+
{
37+
return [];
38+
}
3439
}

src/Transports/Transport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,9 @@ public function encodeBody($data)
230230
$this->getClient()->setHeader('Content-Type', static::JSON_MIME_TYPE);
231231
return json_encode($data);
232232
}
233+
234+
public function getResponseHeaders(): array
235+
{
236+
return iterator_to_array($this->getClient()->getResponseHeaders());
237+
}
233238
}

src/Transports/TransportInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ public function rawRequest($endpoint, array $data = [], $method = 'get');
2929
* @return mixed
3030
*/
3131
public function request($endpoint, array $data = [], $method = 'get');
32+
33+
public function getResponseHeaders(): array;
3234
}

0 commit comments

Comments
 (0)