Browser String not available when run with plackup
Hi, I want to find the Browser string something that is available with $ENV{HTTP_USER_AGENT} when I run a Da*ncer app with teh default backend. However when I run the app with plackup (plackup -s Starman app.pl) $ENV{HTTP_USER_AGENT} is undefined. Is there a way I can get to this value that does not depend on how I run the Dancer application? Thank you. *
On Wednesday 20 July 2011 06:27:37 Gurunandan Bhat wrote:
I want to find the Browser string something that is available with $ENV{HTTP_USER_AGENT} when I run a Da*ncer app with teh default backend. However when I run the app with plackup (plackup -s Starman app.pl) $ENV{HTTP_USER_AGENT} is undefined.
You're better off using request->user_agent rather than poking around in %ENV.
Is there a way I can get to this value that does not depend on how I run the Dancer application?
Please try the above first. If you find that request->user_agent isn't getting you the user agent when run via plackup, something odd is happening; supplying a dump of request->env may be helpful. -- David Precious ("bigpresh") http://www.preshweb.co.uk/ "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
Thanks David. *request->user_agent* works in both cases (with Dancer's backend as well as with plackup). Would appreciate understanding why using %ENV for this is not a good idea. On Wed, Jul 20, 2011 at 3:11 AM, David Precious <davidp@preshweb.co.uk>wrote:
On Wednesday 20 July 2011 06:27:37 Gurunandan Bhat wrote:
I want to find the Browser string something that is available with $ENV{HTTP_USER_AGENT} when I run a Da*ncer app with teh default backend. However when I run the app with plackup (plackup -s Starman app.pl) $ENV{HTTP_USER_AGENT} is undefined.
You're better off using request->user_agent rather than poking around in %ENV.
Is there a way I can get to this value that does not depend on how I run the Dancer application?
Please try the above first. If you find that request->user_agent isn't getting you the user agent when run via plackup, something odd is happening; supplying a dump of request->env may be helpful.
-- David Precious ("bigpresh") http://www.preshweb.co.uk/
"Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
On Wednesday 20 July 2011 14:06:12 Gurunandan Bhat wrote:
Thanks David. *request->user_agent* works in both cases (with Dancer's backend as well as with plackup).
Good stuff, glad to hear it :)
Would appreciate understanding why using %ENV for this is not a good idea.
Well, for one reason, it doesn't always work ;) Dancer gets the request via PSGI and makes stuff available to you through the DSL cleanly and safely; when you're poking around in %ENV directly, you're "going behind Dancer's back", so it can't help you there.
participants (2)
-
David Precious -
Gurunandan Bhat