RejectedSoftware Forums

Sign up

How to check HttpServerRequest headers?

I'd like to use the UrlRouter as demonstrated in the various examples.
However, the delegates it maps urls to only take an HttpServerRequest and
an HttpServerResponse and I can't find any way to get at the request's
HTTP headers. Specifically, I'd like to check the "Accept" header and
render different versions of a template accordingly.
Is there a reason headers are not included in the HttpServerRequest class?

Justin

Re: How to check HttpServerRequest headers?

Am 01.01.1970 01:00, schrieb Justin Whear:

I'd like to use the UrlRouter as demonstrated in the various examples.
However, the delegates it maps urls to only take an HttpServerRequest and
an HttpServerResponse and I can't find any way to get at the request's
HTTP headers. Specifically, I'd like to check the "Accept" header and
render different versions of a template accordingly.
Is there a reason headers are not included in the HttpServerRequest class?

Justin

It's in the base class: HttpRequest.headers
StrMapCI btw. behaves just like a normal string[string] map but the key
is case insensitive.

(I just put a new item on my TODO list to add inherited members to the
API docs of a derived class)

Re: How to check HttpServerRequest headers?

On Wednesday, 22 August 2012 at 20:34:12 UTC, Sönke Ludwig wrote:

Am 01.01.1970 01:00, schrieb Justin Whear:

I'd like to use the UrlRouter as demonstrated in the various
examples.
However, the delegates it maps urls to only take an
HttpServerRequest and
an HttpServerResponse and I can't find any way to get at the
request's
HTTP headers. Specifically, I'd like to check the "Accept"
header and
render different versions of a template accordingly.
Is there a reason headers are not included in the
HttpServerRequest class?

Justin

It's in the base class: HttpRequest.headers
StrMapCI btw. behaves just like a normal string[string] map but
the key is case insensitive.

(I just put a new item on my TODO list to add inherited members
to the API docs of a derived class)

Awesome, I figured I had to be missing something.

Re: How to check HttpServerRequest headers?

On 2052-12-31 04:00:00 +0000, Justin Whear said:

I'd like to use the UrlRouter as demonstrated in the various examples.
However, the delegates it maps urls to only take an HttpServerRequest and
an HttpServerResponse and I can't find any way to get at the request's
HTTP headers. Specifically, I'd like to check the "Accept" header and
render different versions of a template accordingly.
Is there a reason headers are not included in the HttpServerRequest class?

Justin

Hmm.. Somebodies clock is wrong. Vibe-D should allow messages from
the future, or if it does, reset them to it's current time? This
message is now permanently showing at the top of the newsgroup in my
client.

Re: How to check HttpServerRequest headers?

On Sat, 23 Nov 2013 11:05:50 -0500, Shammah Chancellor wrote:

On 2052-12-31 04:00:00 +0000, Justin Whear said:

I'd like to use the UrlRouter as demonstrated in the various examples.
However, the delegates it maps urls to only take an HttpServerRequest and
an HttpServerResponse and I can't find any way to get at the request's
HTTP headers. Specifically, I'd like to check the "Accept" header and
render different versions of a template accordingly.
Is there a reason headers are not included in the HttpServerRequest class?

Justin

Hmm.. Somebodies clock is wrong. Vibe-D should allow messages from
the future, or if it does, reset them to it's current time? This
message is now permanently showing at the top of the newsgroup in my
client.

I'm not sure how this happened, but the message was missing a "Date" header (your client obviously interprets that as 2053, while mine displays 1970). The strange thing is that there is an explicit check to fill in missing "Date" values.

Anyway, I've added code to fix up all such messages, so everything is correct now. It will probably require to resubscribe to this sub group, though.