User-Agent in request

27 views
Skip to first unread message

Michal Harakal

unread,
Apr 28, 2011, 2:27:45 AM4/28/11
to Delphi on Rails
Hello,
I need "user-agent" environment variable for browser depending
rendering (e.g. onclick handler for desktop or ontouchend for iPad).
For me looks the dorHTTPStub.pas the right place to insert it into
TActionController's.Request

Best regards,
Michal Harakal

here an diff for patch.

Index: dorHTTPStub.pas
===================================================================
--- dorHTTPStub.pas (revision 169)
+++ dorHTTPStub.pas (working copy)
@@ -942,6 +942,7 @@
O['cookies'] := HTTPInterprete(PSOChar(Request.S['env.cookie']),
true);
O['content-type'] :=
HTTPInterprete(PSOChar(Request.S['env.content-type']), false, ';');
O['accept'] := HTTPInterprete(PSOChar(Request.S['env.accept']),
false, ',');
+ O['user-agent'] := HTTPInterprete(PSOChar(Request.S['env.user-
agent']), false, ',');
end;

pass := GetPassPhrase;

Henri Gourvest

unread,
Apr 28, 2011, 3:41:50 AM4/28/11
to delphi...@googlegroups.com
Hi,

No it is not the right place to do it.
The request object is available from the controller.
This object was not available from the view, so I just added it.

regards

2011/4/28 Michal Harakal <michal....@googlemail.com>



--
Henri Gourvest

Michal Harakal

unread,
Apr 28, 2011, 12:38:34 PM4/28/11
to Delphi on Rails
Hallo Henri,
thank you for your answer.
I'm doing AJAX in the TActionController successor and as the answer
is some generated HTML code, which varies depending on browser. It is
the reason why TActionController not View. Now is the Reguest even
available in the View, what is great.

I just didn't see how easy I could get the "user-agent" from Request.

This just a note how. Maybe it helps somebody.

Request.S['env.user-agent']

Best regards,
Michal Harakal




On 28 Apr., 09:41, Henri Gourvest <hgourv...@gmail.com> wrote:
> Hi,
>
> No it is not the right place to do it.
> The request object is available from the controller.
> This object was not available from the view, so I just added it.
>
> regards
>
> 2011/4/28 Michal Harakal <michal.hara...@googlemail.com>
Reply all
Reply to author
Forward
0 new messages