rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / code / Atom feed
* HTTP_ Headers from clients
@ 2016-10-24  8:16 Olivar Plays
  2016-10-24 12:01 ` Magnus Holm
  2016-10-24 12:02 ` Lin Jen-Shin (godfat)
  0 siblings, 2 replies; 5+ messages in thread
From: Olivar Plays @ 2016-10-24  8:16 UTC (permalink / raw)
  To: Rack Development


[-- Attachment #1.1: Type: text/plain, Size: 1013 bytes --]

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_ ?

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.
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?

Kind regards,
Arne

-- 

--- 
You received this message because you are subscribed to the Google Groups "Rack Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1255 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: HTTP_ Headers from clients
  2016-10-24  8:16 HTTP_ Headers from clients Olivar Plays
@ 2016-10-24 12:01 ` Magnus Holm
  2016-10-24 12:02 ` Lin Jen-Shin (godfat)
  1 sibling, 0 replies; 5+ messages in thread
From: Magnus Holm @ 2016-10-24 12:01 UTC (permalink / raw)
  To: rack-devel

[-- Attachment #1: Type: text/plain, Size: 2175 bytes --]

Hi Arne,

When the client sends a request which looks like this:

GET / HTTP/1.1
Host: example.com
Company: Acme

The server you're using will always create the following environment:

{
  'HTTP_COMPANY' => 'Acme',
  'HTTP_HOST' => 'example.com',
  …
}

If the client sends a request which looks like this:

GET / HTTP/1.1
Host: example.com
Http-Company: Acme

Then the environment will look like this:

{
  'HTTP_HTTP_COMPANY' => 'Acme',
  'HTTP_HOST' => 'example.com',
  …
}.

So yes: If you're using Rack directly, you will need to use HTTP_COMPANY on
the server-side, and that will correspond to the "Company" header sent from
the client.


// Magnus Holm

On Mon, Oct 24, 2016 at 10:16 AM, Olivar Plays <arne.de.herdt@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_ ?
>
> 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.
> 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?
>
> Kind regards,
> Arne
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Rack Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rack-devel+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups "Rack Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 3600 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: HTTP_ Headers from clients
  2016-10-24  8:16 HTTP_ Headers from clients Olivar Plays
  2016-10-24 12:01 ` Magnus Holm
@ 2016-10-24 12:02 ` Lin Jen-Shin (godfat)
  2016-10-24 12:28   ` Olivar Plays
  1 sibling, 1 reply; 5+ messages in thread
From: Lin Jen-Shin (godfat) @ 2016-10-24 12:02 UTC (permalink / raw)
  To: rack-devel

Hi,

On Mon, Oct 24, 2016 at 4:16 PM, Olivar Plays <arne.de.herdt@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

-- 

--- 
You received this message because you are subscribed to the Google Groups "Rack Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: HTTP_ Headers from clients
  2016-10-24 12:02 ` Lin Jen-Shin (godfat)
@ 2016-10-24 12:28   ` Olivar Plays
  2016-10-24 15:32     ` James Tucker
  0 siblings, 1 reply; 5+ messages in thread
From: Olivar Plays @ 2016-10-24 12:28 UTC (permalink / raw)
  To: Rack Development


[-- Attachment #1.1: Type: text/plain, Size: 2041 bytes --]

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 
> <javascript:>> 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 
>

-- 

--- 
You received this message because you are subscribed to the Google Groups "Rack Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 2721 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: HTTP_ Headers from clients
  2016-10-24 12:28   ` Olivar Plays
@ 2016-10-24 15:32     ` James Tucker
  0 siblings, 0 replies; 5+ messages in thread
From: James Tucker @ 2016-10-24 15:32 UTC (permalink / raw)
  To: Rack Development

[-- Attachment #1: Type: text/plain, Size: 2507 bytes --]

http://www.rubydoc.info/github/rack/rack/file/SPEC#The_Environment

On Oct 24, 2016 5:28 AM, "Olivar Plays" <arne.de.herdt@gmail.com> wrote:

> 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
>>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Rack Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rack-devel+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups "Rack Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rack-devel+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 3534 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-10-24 15:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-24  8:16 HTTP_ Headers from clients Olivar Plays
2016-10-24 12:01 ` Magnus Holm
2016-10-24 12:02 ` Lin Jen-Shin (godfat)
2016-10-24 12:28   ` Olivar Plays
2016-10-24 15:32     ` James Tucker

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/rack.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).