diff --git a/CHANGELOG.md b/CHANGELOG.md index c7f0fc2..a42d6c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Generic fieldtype passes `content_id` along to core fieldtype handler and triggers `pre_process` hook. - Error checking and handling for GraphQL compatible fieldtypes - Trigger `core_boot` hook during GraphQL requests +- Handling of blank headers in HTTP responses - Custom field orderby clauses when it uses legacy field data storage ## [1.1.2] - 2023-07-27 diff --git a/src/Response.php b/src/Response.php index 9ee58c6..59ac57e 100644 --- a/src/Response.php +++ b/src/Response.php @@ -257,14 +257,16 @@ public static function fromOutput($status = 200) // Transform headers that have already been set on the request // to the correct format ["header_name" => "value"] $headers = array_reduce(headers_list(), function ($carry, $header) use ($exclude) { - $pieces = explode(': ', $header); + $pieces = explode(':', $header); + $name = trim($pieces[0]); + $value = $pieces[1] ?? ''; - if (! in_array(strtolower($pieces[0]), $exclude)) { - $carry[$pieces[0]] = $pieces[1]; + if (! in_array(strtolower($name), $exclude)) { + $carry[$name] = trim($value); } // Remove the already set header to avoid duplicates in the response - header_remove($pieces[0]); + header_remove($name); return $carry; }, []);