Skip to content

Conversation

nuryagdym
Copy link
Contributor

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.

@symfony-bot
Copy link

symfony-bot bot commented Aug 28, 2022

Thanks for your pull request! We love contributions.

However, this repository is what we call a "subtree split": a read-only copy of one directory of the main Symfony repository. It is used by Composer to allow developers to depend on specific Symfony components.

If you want to contribute, you should instead open a pull request on the main repository:

https://github.com/symfony/symfony

Thank you for your contribution!

PS: if you haven't already, please add tests, and beware that bug fixes should be submitted on the lowest maintained branch where they apply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant