b0VIM 7.4      DvT' p  sawyer                                  trix                                    ~sawyer/code/personal/Dancer2/lib/Dancer2/Core/Request.pm                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          3210    #"! U                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 tp                                                            S                                        r                                                            @       	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ad                                 x  o  ^  ]  C                }  f  e  U  T            G                e  d                            p  o  F  E  1  0      
  
  
  
  
  
  
  
  
  
  
  
  x
  w
  c
  b
  H
  G
  A
  @
  	  	  	  	  P	  	  	  	  	              n  ^  O  @  4  %                  A  :  8  7  $  #              l  I  /  .                      }  p  [  C  (  %  $  #                    Y  X  )  (                        f  F  D  C  B  3  2  	                    has path => (  =cut  Return the path requested by the client.  =method path()   }       : $self->vars->{ $_[0] };       ? $self->vars->{ $_[0] } = $_[1]     @_ == 2     my $self = shift; sub var {  =cut  will set it.    $request->var('some_variable' => 'value');  returns the value of 'some_variable', while    my $stored = $request->var('some_variable');  By-name interface to variables stored in this request object.  =method var  );     default => sub { {} },     isa     => HashRef,     is      => 'ro', has vars => ( # a buffer for per-request variables   );     default => sub { {} },     isa     => HashRef,     is      => 'ro', has env => ( # then all the native attributes  =cut  Return the current PSGI environment hash reference.  =method env()   our $XS_PARSE_QUERY_STRING = !$@; eval { require CGI::Deurl::XS; };  our $XS_URL_DECODE = !$@; eval { require URL::Encode::XS; }; # check presence of XS module to speedup request  =cut  Dancer2::Core::Request will use it if they detect their presence.  Install URL::Encode::XS and CGI::Deurl::XS for extra speed.  =head1 EXTRA SPEED  }     );         default => sub { $_[0]->env->{ 'HTTP_' . ( uc $attr ) } },         lazy    => 1,         isa     => Maybe[Str],         is      => 'ro',     has $attr => ( foreach my $attr ( @http_env_keys ) {  /);     x_requested_with     user_agent     referer     keep_alive     connection     accept_type     accept_language     accept_encoding     accept_charset     accept my @http_env_keys = (qw/ # (HOST is managed manually) # add an attribute for each HTTP_* variables  =cut  C<HTTP_X_REQUESTED_WITH> in the PSGI env hashref. C<HTTP_>. For example, a C<X-Requested-With> header has the key Note that the L<PSGI> specification prefixes client-supplied request headers with  hash reference. With the exception of C<host>, these accessors are lookups into the PSGI env  =back  =item C<x_requested_with>  =item C<user_agent>  =item C<remote_address>  =item C<referer>  =item C<path_info>  =item C<keep_alive>  =item C<host>  =item C<forwarded_host>  =item C<forwarded_protocol>  =item C<forwarded_for_address>  =item C<connection>  =item C<agent> (alias for C<user_agent>)  =item C<accept_type>  =item C<accept_language>  =item C<accept_encoding>  =item C<accept_charset>  =item C<accept>  =over 4  specific accessors, here are those supported: Commonly used client-supplied HTTP request headers are available through  =head1 Common HTTP request headers  use the current request object. A route handler should not read the environment by itself, but should instead      };         # ...         request->path; # the path requested by the client         request->body; # returns the request body, unparsed         request->params; # request, params parsed as a hash ref     get '/foo' => sub {  method, like in the following example: In a route handler, the current request object can be accessed by the C<request>  =head1 SYNOPSIS  a Dancer2 application. This class implements a common interface for accessing incoming requests in  =head1 DESCRIPTION  with 'Dancer2::Core::Role::Headers';  use Dancer2::Core::Cookie; use Dancer2::Core::Request::Upload; use Dancer2::Core::Types;  use URI::Escape; use URI; use HTTP::Body; use Encode; use Carp;  use Moo;  # ABSTRACT: Interface for accessing incoming requests  package Dancer2::Core::Request; ad  1  M	     @           f  1              O  (                    ?                         u  \  F  E            Y  "    
  {
  g
  I
  
  	  	  	  	  v	  t	  s	  p	  o	  _	  ^	  S	  R	  M	  L	                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   =cut  L<Dancer2>  =head1 SEE ALSO  1;  }     return $cookies;     }           Dancer2::Core::Cookie->new( name => $name, value => \@values );         $cookies->{$name} =         }             @values = map { uri_unescape($_) } split( /[&;]/, $value );         if ( $value ne '' ) {         my @values;         my ( $name, $value ) = split( /\s*=\s*/, $cookie, 2 );         # we want `cookie_name' as the value and `foo=bar' as the value         # cookie_name="foo=bar"         # a cookie string can contains something like:         # here, we don't want more than the 2 first elements      foreach my $cookie ( split( /[,;]\s/, $http_cookie ) ) {      return $cookies unless defined $http_cookie; # nothing to do     my $http_cookie = $self->header('Cookie');      my $cookies = {};     my $self    = shift; sub _build_cookies {  );     builder => '_build_cookies',     lazy    => 1,     isa     => HashRef,     is      => 'ro', has cookies => (  =cut  cookies and values are L<Dancer2::Core::Cookie> objects. Returns a reference to a hash containing cookies, where the keys are the names of the  =method cookies()  }     $self->_build_params();     $self->{uploads} = \%uploads;      }           @filenames > 1 ? \@filenames : $filenames[0];         $self->{_body_params}{$name} =         my @filenames = map { $_->{filename} } @uploads;         # support access to the filename as a normal param          $uploads{$name} = @uploads > 1 ? \@uploads : $uploads[0];         }             );                 )                     filename => $upload->{filename},                     size     => $upload->{size},                     tempname => $upload->{tempname},                     headers  => $upload->{headers}, 