| 1 | package Dancer::Handler::Debug; | ||||||||||||
| 2 | 2 | our $AUTHORITY = 'cpan:SUKRIA'; | |||||||||||
| 3 | #ABSTRACT: a debug handler for easy tracing | ||||||||||||
| 4 | 2 | $Dancer::Handler::Debug::VERSION = '1.3520'; | |||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 2 | ▶ | use HTTP::Headers; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | ▶ | use HTTP::Server::Simple::PSGI; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | ▶ | use base 'Dancer::Object', 'Dancer::Handler', 'HTTP::Server::Simple::PSGI'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | |||||||||||||
| 12 | 2 | ▶ | use Dancer::Config 'setting'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 2 | ▶ | use Dancer::SharedData; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | sub run { | ||||||||||||
| 16 | 2 | ▶ | my ($self, $req) = @_; | ||||||||||
|
Subroutine
run: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 17 | |||||||||||||
| 18 | 2 | my ($method, $path, $query, @env ) = @ARGV; | |||||||||||
| 19 | 2 | my $host = "127.0.0.1"; | |||||||||||
| 20 | 2 | my $port = "3000"; | |||||||||||
| 21 | |||||||||||||
| 22 | my $env = { | ||||||||||||
| 23 | 'HTTP_ACCEPT' => '*/*', | ||||||||||||
| 24 | 'HTTP_HOST' => "$host:$port", | ||||||||||||
| 25 | 'HTTP_USER_AGENT' => 'curl', | ||||||||||||
| 26 | 'QUERY_STRING' => $query, | ||||||||||||
| 27 | 'REMOTE_ADDR' => "$host:$port", | ||||||||||||
| 28 | 'REMOTE_HOST' => "$host:$port", | ||||||||||||
| 29 | 'REQUEST_METHOD' => $method, | ||||||||||||
| 30 | 'REQUEST_URI' => $path, | ||||||||||||
| 31 | 'SERVER_NAME' => $host, | ||||||||||||
| 32 | 'SERVER_PORT' => $port, | ||||||||||||
| 33 | 'SERVER_PROTOCOL' => 'HTTP/1.1', | ||||||||||||
| 34 | 'SERVER_SOFTWARE' => 'HTTP::Server::Simple/0.41', | ||||||||||||
| 35 | 'SERVER_URL' => "http://$host:$port/", | ||||||||||||
| 36 | 2 | ▶ | map { /=/ ? split /=/, $_, 2 : () } @env | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 37 | }; | ||||||||||||
| 38 | |||||||||||||
| 39 | 2 | $req = Dancer::Request->new(env => $env); | |||||||||||
| 40 | |||||||||||||
| 41 | 2 | my $headers = HTTP::Headers->new( | |||||||||||
| 42 | 'User-Agent' => 'curl', | ||||||||||||
| 43 | 'Host', "$host:$port", | ||||||||||||
| 44 | 'Accept', '*/*' | ||||||||||||
| 45 | ); | ||||||||||||
| 46 | 2 | $req->headers($headers); | |||||||||||
| 47 | |||||||||||||
| 48 | # now simulate a PSGI response for the current request only | ||||||||||||
| 49 | 2 | ▶ | my $res = eval { $self->{psgi_app}->($env) } | ||||||||||
|
Condition50%1/2
eval {
do {
$self->{'psgi_app'}->($env)
}
} || [500, ['Content-Type', 'text/plain'], ['Internal Server Error']]
MC/DC0%0/1
eval {
do {
$self->{'psgi_app'}->($env)
}
} || [500, ['Content-Type', 'text/plain'], ['Internal Server Error']]
eval {
do {
$self->{'psgi_app'}->($env)
}
}
Truth table50%1/2
A
A= eval {
do {
$self->{'psgi_app'}->($env)
}
}
| |||||||||||||
| 50 | || [500, ['Content-Type', 'text/plain'], ["Internal Server Error"]]; | ||||||||||||
| 51 | |||||||||||||
| 52 | 2 | $self->_handle_response($res); | |||||||||||
| 53 | 2 | print "\n"; | |||||||||||
| 54 | |||||||||||||
| 55 | 2 | return $res; | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | sub start { | ||||||||||||
| 59 | 2 | ▶ | my ($self, $req) = @_; | ||||||||||
|
Subroutine
start: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 60 | 2 | ▶ | print STDERR ">> Dancer dummy debug server\n" if setting('startup_info'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 61 | |||||||||||||
| 62 | 2 | my $dancer = Dancer::Handler::Debug->new(); | |||||||||||
| 63 | my $psgi = sub { | ||||||||||||
| 64 | 2 | ▶ | my $env = shift; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 65 | 2 | my $req = Dancer::Request->new(env => $env); | |||||||||||
| 66 | 2 | $dancer->handle_request($req); | |||||||||||
| 67 | 2 | }; | |||||||||||
| 68 | 2 | $dancer->{psgi_app} = $psgi; | |||||||||||
| 69 | 2 | $dancer->run($req); | |||||||||||
| 70 | } | ||||||||||||
| 71 | |||||||||||||
| 72 | 2 | ▶ | sub dance { start(@_) } | ||||||||||
|
Subroutine
dance: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 73 | 2 | 1; | |||||||||||
| 74 | |||||||||||||
| 75 | __END__ | ||||||||||||