File Coverage

blib/lib/Protocol/WebSocket/Cookie/Response.pm
Criterion Covered Total %
statement 26 28 92.8
branch 13 16 81.2
condition n/a
subroutine 4 5 80.0
pod 2 2 100.0
total 45 51 88.2


line stmt bran cond sub pod time code
1             package Protocol::WebSocket::Cookie::Response;
2              
3 15     15   930 use strict;
  15         36  
  15         431  
4 15     15   80 use warnings;
  15         31  
  15         457  
5              
6 15     15   82 use base 'Protocol::WebSocket::Cookie';
  15         30  
  15         4450  
7              
8             sub parse {
9 0     0 1 0 my $self = shift;
10              
11 0         0 $self->SUPER::parse(@_);
12             }
13              
14             sub to_string {
15 20     20 1 34 my $self = shift;
16              
17 20         29 my $pairs = [];
18              
19 20         45 push @$pairs, [$self->{name}, $self->{value}];
20              
21 20 50       44 push @$pairs, ['Comment', $self->{comment}] if defined $self->{comment};
22              
23             push @$pairs, ['CommentURL', $self->{comment_url}]
24 20 50       38 if defined $self->{comment_url};
25              
26 20 100       27 push @$pairs, ['Discard'] if $self->{discard};
27              
28 20 100       38 push @$pairs, ['Max-Age' => $self->{max_age}] if defined $self->{max_age};
29              
30 20 100       42 push @$pairs, ['Path' => $self->{path}] if defined $self->{path};
31              
32 20 100       35 if (defined $self->{portlist}) {
33             $self->{portlist} = [$self->{portlist}]
34 2 100       6 unless ref $self->{portlist} eq 'ARRAY';
35 2         4 my $list = join ' ' => @{$self->{portlist}};
  2         5  
36 2         5 push @$pairs, ['Port' => "\"$list\""];
37             }
38              
39 20 50       34 push @$pairs, ['Secure'] if $self->{secure};
40              
41 20         36 push @$pairs, ['Version' => '1'];
42              
43 20         58 $self->pairs($pairs);
44              
45 20         42 return $self->SUPER::to_string;
46             }
47              
48             1;
49             __END__