[Dancer-users] working with HTTP env vars

P Kishor punk.kish at gmail.com
Fri Aug 20 02:52:58 CEST 2010


On Thu, Aug 19, 2010 at 7:20 PM, P Kishor <punk.kish at gmail.com> wrote:
> On Thu, Aug 19, 2010 at 5:09 PM, Olaf Alders <olaf at wundersolutions.com> wrote:
>> On 2010-08-19, at 3:27 PM, P Kishor wrote:
>>
>>>>> As far as your setup goes, you may want to at least consider something like this:
>>>>
>>>> http://advent.plackperl.org/2009/12/day-12-maps-multiple-apps-with-mount-and-urlmap.html
>>>>
>>>> "The environment variables such as PATH_INFO and SCRIPT_NAME are automatically adjusted so it just works like when your application is mounted using Apache's mod_alias or CGI scripts. Your application framework should always use PATH_INFO to dispatch requests, and concatenate with SCRIPT_NAME to build links."
>>>>
>>>> This should get you pretty much to the same place, but with the added advantage of being able to use Plack's debug panels etc.
>>>>
>>>> Hope this helps,
>>>>
>>>
>>> wow! That Plack advent calendar is brilliant. I am learning a lot from
>>> it, however, I am not sure it helps me. Since I am already using
>>> Dancer, I am "supposed" to be shielded from dealing with Plack
>>> directly, no? In other words, (from the quote above), Dancer should
>>> give me access to PATH_INFO and SCRIPT_NAME, etc. Which is precisely
>>> what I want.
>>
>>
>> Could you post a dump of your request->env ?
>
>
> this may sound very dumb, but I frankly don't know how to dump a data
> structure. How do I dump the entire request->env()?
>
>


ok, figured it out. I set log level to debug, and then wrote

debug to_dumper(request->env())

which gave me the following

$VAR1 = {
          'psgi.multiprocess' => 1,
          'SCRIPT_NAME' => '',
          'PATH_INFO' => '/',
          'HTTP_ACCEPT' =>
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
          'REQUEST_METHOD' => 'GET',
          'psgi.multithread' => '',
          'SCRIPT_FILENAME' => '/Users/punkish/Sites/lca/',
          'SERVER_SOFTWARE' => 'Apache/2.2.16 (Unix) DAV/2
mod_perl/2.0.4 Perl/v5.12.1',
          'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac
OS X 10.6; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8',
          'REMOTE_PORT' => '60500',
          'QUERY_STRING' => '',
          'SERVER_SIGNATURE' => '',
          'HTTP_CACHE_CONTROL' => 'max-age=0',
          'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5',
          'HTTP_KEEP_ALIVE' => '115',
          'psgi.streaming' => 1,
          'PATH' => '/usr/bin:/bin:/usr/sbin:/sbin',
          'MOD_PERL_API_VERSION' => '2',
          'GATEWAY_INTERFACE' => 'CGI/1.1',
          'psgi.version' => [
                              1,
                              1
                            ],
          'DOCUMENT_ROOT' => '/Users/punkish/Sites/lca',
          'psgi.run_once' => '',
          'UNIQUE_ID' => 'TG3RfsCoAWcAAPtoA2EAAAAJ',
          'SERVER_NAME' => 'lca.local',
          'SERVER_ADMIN' => 'punkish at eidesis.org',
          'HTTP_ACCEPT_ENCODING' => 'gzip,deflate',
          'HTTP_CONNECTION' => 'keep-alive',
          'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
          'SERVER_PORT' => '80',
          'REMOTE_ADDR' => '127.0.0.1',
          'SERVER_PROTOCOL' => 'HTTP/1.1',
          'psgi.errors' => *::STDERR,
          'REQUEST_URI' => '/',
          'psgi.nonblocking' => '',
          'SERVER_ADDR' => '127.0.0.1',
          'psgi.url_scheme' => 'http',
          'HTTP_HOST' => 'lca.local',
          'MOD_PERL' => 'mod_perl/2.0.4',
          'psgi.input' => bless( do{\(my $o = 4305081000)},
'Apache2::RequestRec' )
        }; in /Users/punkish/Sites/lca/lib/lca.pm l. 10

-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================


More information about the Dancer-users mailing list