We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents fd81b8d + b106010 commit df5edacCopy full SHA for df5edac
1 file changed
src/WP_REST_PSR7_Response.php
@@ -95,10 +95,20 @@ class WP_REST_PSR7_Response extends \WP_REST_Response implements ResponseInterfa
95
*/
96
public static function fromPSR7Response(ResponseInterface $response)
97
{
98
+ // Since PSR7 response has the headers as an array of arrays,
99
+ // we need to convert it to a simple associative array
100
+ $headers = [];
101
+ $responseHeaders = $response->getHeaders();
102
+ foreach ($responseHeaders as $name => $values) {
103
+ // Set the first value as the header value
104
+ if (isset($values[0])) {
105
+ $headers[$name] = $values[0];
106
+ }
107
108
return new self(
109
(string)$response->getBody(),
110
$response->getStatusCode(),
- $response->getHeaders()
111
+ $headers,
112
);
113
}
114
0 commit comments