HTTPServer/ParameterParseHandler.pm

filter: Statementstmt 97.1% 34 / 35 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 93.8% 46 / 49 CC 5 SCAR 10.5
CC
5
Cov
93%
handle
5.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.8
« HTTPServer/TemplateHandler.pm ↑ Summary HTTPServer/BasicAuthenHandler.pm »
1 package POE::Component::Server::HTTPServer::ParameterParseHandler;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use HTTP::Status;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use MIME::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use URI::Escape qw(uri_unescape);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use POE::Component::Server::HTTPServer::Handler;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use base 'POE::Component::Server::HTTPServer::Handler';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #
10 # problems to fix:
11 # multi-valued params
12 # mutlipart form data
13 # the hash copying at the end of the POST handling could be more efficient
14 #
15 4 ▶sub handle {
Subroutine handle: called CC=5 SCAR=16.2
Pod documented
16 4 my $self = shift;
17 4 my $context = shift;
18 4 my $req = $context->{request};
19 # technically, for POST requests we could ignore (uri-)query params
20 # might as well grab them, though
21 4 my %p = $req->uri->query_form;
22 4 $context->{param} = \%p;
23 4 ▶ if ( $req->method eq 'POST' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->method eq "POST") 2 2 4
24 2 ▶ if ( $req->content_type ne 'application/x-www-form-urlencoded' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($req->content_type ne 'application/x-www-form-urlencoded') { } 0 2 2
25 0 print "XXX Don't know how to handle POST content encoding: ",
26 $req->content_type, "\n";
27 } else {
28 2 my $querydata = $req->content;
29 # following mapmap stolen from URI::_query
30 6 my %bodyp = map { s/\+/ /g; uri_unescape($_) }
31 2 ▶ map { /=/ ? split(/=/, $_, 2) : ($_ => '')} split(/&/, $querydata);
Branch: 1 branch
BranchTrueFalseTotal
/=/ ? : 3 0 3
32 2 foreach my $k (keys %bodyp) {
33 3 $context->{param}->{$k} = $bodyp{$k};
34 }
35 }
36 }
37 4 return H_CONT;
38 }
39  
40 1 1;
41 __END__
« HTTPServer/TemplateHandler.pm ↑ Summary HTTPServer/BasicAuthenHandler.pm »