Alright,
then we just need use some documentation and properly communicate this.
At least I know where it stands now with Rack and can deal with it appropriately.
Thank you for the information.
Kind regards,
Arne
Op maandag 24 oktober 2016 14:25:15 UTC+2 schreef Lin Jen-Shin:
Hi,
On Mon, Oct 24, 2016 at 4:16 PM, Olivar Plays <arne.d...@gmail.com> wrote:
> Hello,
>
> I have a small question about the behaviour of Rack when it comes to headers
> send by clients.
> Are these always prefixed with HTTP_ ? Or do I need to tell my clients to
> explicitly send them as HTTP_ ?
I think according to Rack SPEC, all headers sent from client should be prefixed
with HTTP_, and if your client prefix HTTP_, then you'll end up seeing
HTTP_HTTP_ in your Rack application.
> Example, I'm checking on every request in my Rails application whether the
> HTTP_COMPANY header is present, and has the correct value.
> But I've been running into issues with detecting them.
> Right now I have the client app send the headers as COMPANY, and my Rails
> app checks as HTTP_COMPANY.
This is intended.
> Is this the intended behaviour, or will this go wrong again when the client
> suddenly submits the header as HTTP_COMPANY?
> e.g is Rack smart enough not to prefix HTTP_COMPANY with HTTTP_ again?
As stated above, if your client is sending HTTP_COMPANY, then you'll need to
access it via HTTP_HTTP_COMPANY in your Rack application. Rack should
not try to remove the prefix, otherwise HTTP_COMPANY and COMPANY
would be ambiguous.
It's designed this way to mix HTTP headers into env unambiguously.
> Kind regards,
> Arne