Engine/Role/RequestBuilder/Standard.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 43 SCAR 30.0
CC
4
Cov
0%
BEGIN
12.0
_build_cookies
6.0
_build_hostname
2.0
CRAP 20.0
1 package HTTP::Engine::Role::RequestBuilder::Standard;
2 use Any::Moose '::Role';
3  
4 use Socket qw[AF_INET inet_aton];
5  
6 with qw(HTTP::Engine::Role::RequestBuilder);
7 use CGI::Simple::Cookie ();
8  
9 sub _build_cookies {
10 my($self, $req) = @_;
11  
12 if (my $header = $req->header('Cookie')) {
13 return { CGI::Simple::Cookie->parse($header) };
14 } else {
15 return {};
16 }
17 }
18  
19 sub _build_hostname {
20 my ( $self, $req ) = @_;
21 gethostbyaddr( inet_aton( $req->address ), AF_INET );
22 }
23  
24 # for win32 hacks
25 BEGIN {
26 if ($^O eq 'MSWin32') {
27 no warnings 'redefine';
28 *_build_hostname = sub {
29 my ( $self, $req ) = @_;
30 my $address = $req->address;
31 return 'localhost' if $address eq '127.0.0.1';
32 return gethostbyaddr( inet_aton( $address ), AF_INET );
33 };
34 }
35 }
36  
37 1;