You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Headers are Case Sensitive - Saloon Response Class #482
First off, love the framework, has brought law and order to my wild west of API code 🤠
I recently however had an issue with headers. The HTTP standard defines that HTTP headers are designed to be case insensitive. Meaning it shouldn't matter if the API I am consuming presents its headers in Title-Case or in lower-case. Developers are expected to present headers in lowercase, but code should be assessing them all in lowercase regardless.
As an example, if I sent a header X-My-Custom-Header:
When using Saloon, you will get different results when using $response->header('x-my-custom-header'); vs using Guzzle/PSR7's$response->getPsrResponse()->getHeader('x-my-custom-header');, due to the way Guzzle lowercases all headers and lowercases users input to the function.
@JonPurvis I am not convinced that solves this specific issue, as the mentioned PR only changed it when detecting the response type and not the header method itself. When we look at the headers method on the Response class, it still does:
public function header(string $header): string|array|null
{
return $this->headers()->get($header);
}
That line is replaced in the PR with accessing the PSR response.
So, that's why I think the $response->header('Content-Type') and $response->header('content-type') still behave differently.
Activity
lamberttraccard commentedon Sep 1, 2025
Just been bitten by this 😓
JonPurvis commentedon Feb 26, 2026
Hey @Cbrad24, @lamberttraccard
We merged #534 earlier this evening which I think should resolve this?
dvdheiden commentedon Mar 1, 2026
@JonPurvis I am not convinced that solves this specific issue, as the mentioned PR only changed it when detecting the response type and not the header method itself. When we look at the
headersmethod on theResponseclass, it still does:That line is replaced in the PR with accessing the PSR response.
So, that's why I think the
$response->header('Content-Type')and$response->header('content-type')still behave differently.JonPurvis commentedon Mar 2, 2026
Whoops, my bad!
I saw "Case Sensitive" and went into autopilot mode 😆
I've created #535 and will try to get it merged this evening and then get a patch version released.