rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
* How to get the request headers from "env" hash?
@ 2009-08-28  0:08 Iñaki Baz Castillo
  2009-08-28  1:05 ` How to get the request headers from "env" hash? [SOLVED] Iñaki Baz Castillo
  0 siblings, 1 reply; 4+ messages in thread
From: Iñaki Baz Castillo @ 2009-08-28  0:08 UTC (permalink / raw)
  To: rack-devel


Hi, I'm just starting with Rack by testing some simple examples.

For now I just would like to know how to get the request headers, as this info 
is not present in "env" hash which just contains:

HTTP_HOST => 127.0.0.1:9292
HTTP_ACCEPT => text/html, image/jpeg;q=0.9, image/png;q=0.9, text/*;q=0.9, 
image/*;q=0.9, */*;q=0.8
SERVER_NAME => 127.0.0.1
rack.url_scheme => http
REQUEST_PATH => /
HTTP_USER_AGENT => Mozilla/5.0 (compatible; Konqueror/4.3; Linux 2.6.28-15-
generic; es, en-GB, en-US, en) KHTML/4.3.0 (like Gecko)
rack.errors => #<IO:0x7f3c3beabab8>
HTTP_ACCEPT_LANGUAGE => es, en-GB, en-US, en
SERVER_PROTOCOL => HTTP/1.1
rack.version => 01
rack.run_once => false
SERVER_SOFTWARE => Mongrel 1.1.5
PATH_INFO => /
REMOTE_ADDR => 127.0.0.1
SCRIPT_NAME =>
rack.multithread => true
HTTP_VERSION => HTTP/1.1
rack.multiprocess => false
REQUEST_URI => /
HTTP_ACCEPT_CHARSET => utf-8, utf-8;q=0.5, *;q=0.5
SERVER_PORT => 9292
REQUEST_METHOD => GET
QUERY_STRING =>
rack.input => #<StringIO:0x7f3c39aaecc8>
HTTP_CONNECTION => Keep-Alive
HTTP_ACCEPT_ENCODING => x-gzip, x-deflate, gzip, deflate
GATEWAY_INTERFACE => CGI/1.2


env["rack.input"] contains a IO object with the request body, but I don't see 
in the above hash how to get the request headers (any header).

Thanks for any help.


-- 
Iñaki Baz Castillo <ibc@aliax.net>

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

* Re: How to get the request headers from "env" hash?
@ 2009-08-28  0:35 Iñaki Baz Castillo
  0 siblings, 0 replies; 4+ messages in thread
From: Iñaki Baz Castillo @ 2009-08-28  0:35 UTC (permalink / raw)
  To: rack-devel


El Viernes, 28 de Agosto de 2009, escribió:
> env["rack.input"] contains a IO object with the request body, but I don't
> see in the above hash how to get the request headers (any header).
>
> Thanks for any help.

There is a class HeaderHash but as far as I realize by inspecting the code, 
it's just used to create the response, and not to store the request headers.

Do I miss something?

Thanks a lot.

-- 
Iñaki Baz Castillo <ibc@aliax.net>

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

* Re: How to get the request headers from "env" hash? [SOLVED]
  2009-08-28  0:08 How to get the request headers from "env" hash? Iñaki Baz Castillo
@ 2009-08-28  1:05 ` Iñaki Baz Castillo
  2009-08-28  1:09   ` Iñaki Baz Castillo
  0 siblings, 1 reply; 4+ messages in thread
From: Iñaki Baz Castillo @ 2009-08-28  1:05 UTC (permalink / raw)
  To: rack-devel


El Viernes, 28 de Agosto de 2009, Iñaki Baz Castillo escribió:
> but I don't see
> in the above hash how to get the request headers (any header).

Ok, it's done by inspecting env["HTTP_HEADER_NAME"].

:)


However, what about if a header is present more than once? AFAIK HTTP protocol 
allows a header having multivalue in two ways:

1) A single header with values separated by comma.
2) Varios headers with same value and different name.

Rack sems to choose the last matching header as I've realized. Then, what 
about multiple headers with same value?

Thanks.


-- 
Iñaki Baz Castillo <ibc@aliax.net>

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

* Re: How to get the request headers from "env" hash? [SOLVED]
  2009-08-28  1:05 ` How to get the request headers from "env" hash? [SOLVED] Iñaki Baz Castillo
@ 2009-08-28  1:09   ` Iñaki Baz Castillo
  0 siblings, 0 replies; 4+ messages in thread
From: Iñaki Baz Castillo @ 2009-08-28  1:09 UTC (permalink / raw)
  To: rack-devel


El Viernes, 28 de Agosto de 2009, Iñaki Baz Castillo escribió:
> However, what about if a header is present more than once? AFAIK HTTP
> protocol allows a header having multivalue in two ways:
>
> 1) A single header with values separated by comma.
> 2) Varios headers with same value and different name.
>
> Rack sems to choose the last matching header as I've realized. Then, what
> about multiple headers with same value?

Perhaps this is a task of the web server since it should take all the values 
of header with same name and encode them as comma separated value?


-- 
Iñaki Baz Castillo <ibc@aliax.net>

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

end of thread, other threads:[~2009-08-28  5:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-28  0:08 How to get the request headers from "env" hash? Iñaki Baz Castillo
2009-08-28  1:05 ` How to get the request headers from "env" hash? [SOLVED] Iñaki Baz Castillo
2009-08-28  1:09   ` Iñaki Baz Castillo
  -- strict thread matches above, loose matches on Subject: below --
2009-08-28  0:35 How to get the request headers from "env" hash? Iñaki Baz Castillo

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