File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,10 +95,24 @@ class WP_REST_PSR7_Response extends \WP_REST_Response implements ResponseInterfa
9595 */
9696 public static function fromPSR7Response (ResponseInterface $ response )
9797 {
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+ // If for some reason the values is a string, we set it directly
104+ if (is_string ($ values )) {
105+ $ headers [$ name ] = $ values ;
106+ }
107+ // Set the first value as the header value
108+ if (isset ($ values [0 ])) {
109+ $ headers [$ name ] = $ values [0 ];
110+ }
111+ }
98112 return new self (
99113 (string )$ response ->getBody (),
100114 $ response ->getStatusCode (),
101- $ response -> getHeaders ()
115+ $ headers ,
102116 );
103117 }
104118
You can’t perform that action at this time.
0 commit comments