Trim response header name #12
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I working on a library that I am working on supports PSR-18 and PSR-7 implementations.
I tried following PSR-7 libraries:
nyholm/psr7
laminas/laminas-diactoros
slim/psr7
and following PSR-18 clients:
php-http/curl-client
symfony/http-client
guzzlehttp/guzzle
and when I tried combination of all these PSR-7 and PSR-18 libraries.
I faced issue only on
symfony/http-client
Psr18Client client.Error is caused when I received response with header name containing leading space " x-xss-protection". This library does not trim response header names that is why all 3 PSR-7 libraries throwing error "Header values must be RFC 7230 compatible strings" when used in combination with
symfony/http-client
.The other 2 PSR-18 clients trim header names:
guzzlehttp/guzzle: GuzzleHttp\Handler\CurlFactory::createHeaderFn()
php-http/curl-client: Http\Client\Curl\Client::prepareRequestOptions()
So, I added trim line on Psr18Client, hope it does not break anything, it is working for me at least.
I guess this fix should be done on all maintained versions of this library as well.
PS
I also, tried to trim using
Symfony\Component\HttpClient\HttpClientTrait::normalizeHeaders()
but it does not do anything about this leading space in the header name.