Skip to content

Commit

Permalink
Simplify default blank header and add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
bryannielsen committed Nov 15, 2023
1 parent 3cfb21b commit f112ba8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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

## [1.1.2] - 2023-07-27

Expand Down
17 changes: 7 additions & 10 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +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);
if (count($pieces) !== 2) {
$pieces = [
rtrim($pieces[0], ':'),
''
];
}
if (! in_array(strtolower($pieces[0]), $exclude)) {
$carry[$pieces[0]] = $pieces[1];
$pieces = explode(':', $header);
$name = trim($pieces[0]);
$value = $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;
}, []);
Expand Down

0 comments on commit f112ba8

Please sign in to comment.