amphp / http-client

An advanced async HTTP client library for PHP, enabling efficient, non-blocking, and concurrent requests and responses.
https://amphp.org/http-client
MIT License
707 stars 66 forks source link

Request headers are lowercased #242

Closed nicolas-grekas closed 4 years ago

nicolas-grekas commented 4 years ago

Same as #164. On Symfony, we've got https://github.com/symfony/symfony/issues/32819 a few months ago.

TL;DR there are API servers that are case sensitive. Yes, this is not HTTP-compliant. Yet, lowercasing the headers before sending them is not required. We chose to not lowercase headers when sending them on HTTP/1.x so that the client can still consume those APIs.

I think the Amp client should reconsider and do the same. At least on Symfony's side, the current strict behavior means we're not sure if we can ship Amp's implementation as the default one (when it is installed).

trowski commented 4 years ago

We could consider adding Request::getOriginalHeaderNames() and Response::getOriginalHeaderNames() so the HTTP/1.x client can use/set those. Thoughts @kelunik?

kelunik commented 4 years ago

@nicolas-grekas Before we start implementing this, did you hear any other complaints or was that the only such request?

nicolas-grekas commented 4 years ago

That's the only report on the topic. But now that this is fixed, we won't get more...

kelunik commented 4 years ago

A related question is whether we want to support specific header ordering. I've stumbled upon this while implementing this in Message.

nicolas-grekas commented 4 years ago

A related question is whether we want to support specific header ordering

Right now ordering is preserved for the first header of each kind, isn't it? I think that's enough, no need for per header line order preservation.