Compiler-Parser
view release on metacpan or search on metacpan
t/app/Plack/App/Directory.t view on Meta::CPAN
module { 'Plack::Request',
},
branch { '=',
left => leaf '$dir_file',
right => leaf '<tr><td class=\'name\'><a href=\'%s\'>%s</a></td><td class=\'size\'>%s</td><td class=\'type\'>%s</td><td class=\'mtime\'>%s</td></tr>',
},
branch { '=',
left => leaf '$dir_page',
right => leaf '<html><head>
<title>%s</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type=\'text/css\'>
table { width:100%%; }
.name { text-align:left; }
.size, .mtime { text-align:right; }
.type { width:11em; }
.mtime { width:15em; }
</style>
</head><body>
<h1>%s</h1>
<hr />
t/app/Plack/App/Directory.t view on Meta::CPAN
use Plack::MIME;
use DirHandle;
use URI::Escape;
use Plack::Request;
# Stolen from rack/directory.rb
my $dir_file = "<tr><td class='name'><a href='%s'>%s</a></td><td class='size'>%s</td><td class='type'>%s</td><td class='mtime'>%s</td></tr>";
my $dir_page = <<PAGE;
<html><head>
<title>%s</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type='text/css'>
table { width:100%%; }
.name { text-align:left; }
.size, .mtime { text-align:right; }
.type { width:11em; }
.mtime { width:15em; }
</style>
</head><body>
<h1>%s</h1>
<hr />
t/app/Plack/Handler/Apache1.t view on Meta::CPAN
},
right => leaf '@_',
},
if_stmt { 'if',
expr => branch { 'eq',
left => function_call { 'lc',
args => [
leaf '$h',
],
},
right => leaf 'content-type',
},
true_stmt => branch { '->',
left => leaf '$r',
right => function_call { 'content_type',
args => [
leaf '$v',
],
},
},
false_stmt => else_stmt { 'else',
t/app/Plack/Handler/Apache1.t view on Meta::CPAN
sub _handle_response {
my ($r, $res) = @_;
my ($status, $headers, $body) = @{ $res };
my $hdrs = ($status >= 200 && $status < 300)
? $r->headers_out : $r->err_headers_out;
Plack::Util::header_iter($headers, sub {
my($h, $v) = @_;
if (lc $h eq 'content-type') {
$r->content_type($v);
} else {
$hdrs->add($h => $v);
}
});
$r->status($status);
$r->send_http_header;
if (defined $body) {
t/app/Plack/Handler/Apache2.t view on Meta::CPAN
},
right => leaf '@_',
},
if_stmt { 'if',
expr => branch { 'eq',
left => function_call { 'lc',
args => [
leaf '$h',
],
},
right => leaf 'content-type',
},
true_stmt => branch { '->',
left => leaf '$r',
right => function_call { 'content_type',
args => [
leaf '$v',
],
},
},
false_stmt => if_stmt { 'elsif',
t/app/Plack/Handler/Apache2.t view on Meta::CPAN
sub _handle_response {
my ($r, $res) = @_;
my ($status, $headers, $body) = @{ $res };
my $hdrs = ($status >= 200 && $status < 300)
? $r->headers_out : $r->err_headers_out;
Plack::Util::header_iter($headers, sub {
my($h, $v) = @_;
if (lc $h eq 'content-type') {
$r->content_type($v);
} elsif (lc $h eq 'content-length') {
$r->set_content_length($v);
} else {
$hdrs->add($h => $v);
}
});
$r->status($status);
t/app/Plack/Util.t view on Meta::CPAN
my $bool = Plack::Util::header_exists($hdrs, $key);
Plack::Util::header_set($hdrs, $key, $val); # overwrites existent header
Plack::Util::header_push($hdrs, $key, $val);
Plack::Util::header_remove($hdrs, $key);
Utility functions to manipulate PSGI response headers array
reference. The methods that read existent header value handles header
name as case insensitive.
my $hdrs = [ 'Content-Type' => 'text/plain' ];
my $v = Plack::Util::header_get($hdrs, 'content-type'); # 'text/plain'
=item headers
my $headers = [ 'Content-Type' => 'text/plain' ];
my $h = Plack::Util::headers($headers);
$h->get($key);
if ($h->exists($key)) { ... }
$h->set($key => $val);
$h->push($key => $val);
( run in 1.658 second using v1.01-cache-2.11-cpan-524268b4103 )