Dancer
view release on metacpan or search on metacpan
lib/Dancer/Deployment.pod view on Meta::CPAN
option httplog
option dontlognull
option forwardfor
option abortonclose
mode http
balance roundrobin
retries 3
timeout connect 5s
timeout server 30s
timeout client 30s
timeout http-keep-alive 200m
# enable compression (haproxy v1.5-dev13 and above required)
compression algo gzip
compression type text/html application/javascript text/css application/x-javascript text/javascript
# application frontend (available at http://app.example.com)
frontend app.example.com
bind :80
# modify request headers
reqadd X-Forwarded-Proto:\ http
reqadd X-Forwarded-Port:\ 80
lib/Dancer/Request.pm view on Meta::CPAN
use Dancer::SharedData;
use Dancer::Session;
use Dancer::Exception qw(:all);
use Encode;
use HTTP::Body;
use URI;
use URI::Escape;
my @http_env_keys = (
'user_agent', 'accept_language', 'accept_charset',
'accept_encoding', 'keep_alive', 'connection', 'accept',
'accept_type', 'referer', #'host', managed manually
);
my $count = 0;
__PACKAGE__->attributes(
# query
'env', 'path', 'method',
'content_type', 'content_length',
'id',
lib/Dancer/Request.pm view on Meta::CPAN
# Don't refactor that, it's called whenever a request object is needed, that
# means at least once per request. If refactored in a loop, this will cost 4
# times more than the following static map.
my $env = $self->env;
$self->{user_agent} = $env->{HTTP_USER_AGENT};
$self->{host} = $env->{HTTP_HOST};
$self->{accept_language} = $env->{HTTP_ACCEPT_LANGUAGE};
$self->{accept_charset} = $env->{HTTP_ACCEPT_CHARSET};
$self->{accept_encoding} = $env->{HTTP_ACCEPT_ENCODING};
$self->{keep_alive} = $env->{HTTP_KEEP_ALIVE};
$self->{connection} = $env->{HTTP_CONNECTION};
$self->{accept} = $env->{HTTP_ACCEPT};
$self->{accept_type} = $env->{HTTP_ACCEPT_TYPE};
$self->{referer} = $env->{HTTP_REFERER};
$self->{x_requested_with} = $env->{HTTP_X_REQUESTED_WITH};
}
sub _build_headers {
my ($self) = @_;
$self->{headers} = Dancer::SharedData->headers;
lib/Dancer/Request.pm view on Meta::CPAN
=item C<forwarded_protocol>
=item C<forwarded_host>
=item C<host>
If you app is on a non-standard port, you can expect this to return the hostname
and port, e.g. C<example.com:5000>.
=item C<keep_alive>
=item C<path_info>
=item C<referer>
=item C<remote_address>
=item C<request_base>
=item C<user_agent>
lib/Dancer/Test.pm view on Meta::CPAN
$headers = HTTP::Headers->new(@{$headers||[]})
unless _isa($headers, "HTTP::Headers");
if ($headers->header('Content-Type')) {
$extra_env->{'CONTENT_TYPE'} = $headers->header('Content-Type');
}
# handle all the keys of Request::_build_request_env():
for my $key (qw( user_agent host accept_language accept_charset
accept_encoding keep_alive connection accept accept_type referer
x_requested_with )) {
my $k = sprintf("HTTP_%s", uc $key);
$extra_env->{$k} = $headers->{$key}
if exists $headers->{$key};
}
# fake the REQUEST_URI
# TODO deal with the params
unless( $extra_env->{REQUEST_URI} ) {
$extra_env->{REQUEST_URI} = $path;
t/02_request/06_init_env.t view on Meta::CPAN
'PATH_INFO' => '/stuff',
'REQUEST_METHOD' => 'GET',
'XAUTHORITY' => '/var/run/gdm/auth-for-sukria-6en6nX/database',
'HTTP_ACCEPT' => 'image/png,image/*;q=0.8,*/*;q=0.5; text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'HTTP_USER_AGENT' => 'Mozilla/5.0 (X11; U; Linux x86_64; fr; rv:1.9.1.5) Gecko/20091109 Ubuntu/9.10 (karmic) Firefox/3.5.5; Mozilla/5.0 (X11; U; Linux x86_64; fr; rv:1.9.1.5) Gecko/20091109 Ubuntu/9.10 (karmic) Firefox/3.5.5',
'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3; fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3',
'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7; ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'HTTP_HOST' => 'localhost:3000; localhost:3000',
'HTTP_KEEP_ALIVE' => '300; 300',
'HTTP_ACCEPT_ENCODING' => 'gzip,deflate; gzip,deflate',
'HTTP_CONNECTION' => 'keep-alive; keep-alive',
};
my @http_env = grep /^HTTP_/, keys (%$custom_env);
plan tests => 6 + (2 * scalar(@http_env));
my $req = Dancer::Request->new(env => $custom_env);
is $req->path, '/stuff', 'path is set from custom env';
is $req->method, 'GET', 'method is set from custom env';
is_deeply scalar($req->params), {foo => 'bar'}, 'params are set from custom env';
is $req->port, 3000, 'port is ok';
t/07_apphandlers/02_apache2_plack.t view on Meta::CPAN
'HTTP_KEEP_ALIVE' => '300',
'MOD_PERL_API_VERSION' => '2',
'PATH' => '/usr/local/bin:/usr/bin:/bin',
'GATEWAY_INTERFACE' => 'CGI/1.1',
'psgi.version' => [ 1, 0 ],
'DOCUMENT_ROOT' => $document_root,
'psgi.run_once' => '',
'SERVER_NAME' => $server_name,
'SERVER_ADMIN' => $server_admin,
'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' => $remote_addr,
'SERVER_PROTOCOL' => 'HTTP/1.1',
'REQUEST_URI' => '/',
'psgi.errors' => *::STDERR,
'SERVER_ADDR' => $server_addr,
'psgi.url_scheme' => 'http',
'HTTP_HOST' => $host_name,
};
( run in 0.921 second using v1.01-cache-2.11-cpan-39bf76dae61 )