1package Protocol::WebSocket::Cookie::Response; 2 3use strict; 4use warnings; 5 6use base 'Protocol::WebSocket::Cookie'; 7 8sub parse { 9 my $self = shift; 10 11 $self->SUPER::parse(@_); 12} 13 14sub to_string { 15 my $self = shift; 16 17 my $pairs = []; 18 19 push @$pairs, [$self->{name}, $self->{value}]; 20 21 push @$pairs, ['Comment', $self->{comment}] if defined $self->{comment}; 22 23 push @$pairs, ['CommentURL', $self->{comment_url}] 24 if defined $self->{comment_url}; 25 26 push @$pairs, ['Discard'] if $self->{discard}; 27 28 push @$pairs, ['Max-Age' => $self->{max_age}] if defined $self->{max_age}; 29 30 push @$pairs, ['Path' => $self->{path}] if defined $self->{path}; 31 32 if (defined $self->{portlist}) { 33 $self->{portlist} = [$self->{portlist}] 34 unless ref $self->{portlist} eq 'ARRAY'; 35 my $list = join ' ' => @{$self->{portlist}}; 36 push @$pairs, ['Port' => "\"$list\""]; 37 } 38 39 push @$pairs, ['Secure'] if $self->{secure}; 40 41 push @$pairs, ['Version' => '1']; 42 43 $self->pairs($pairs); 44 45 return $self->SUPER::to_string; 46} 47 481; 49__END__ 50 51=head1 NAME 52 53Protocol::WebSocket::Cookie::Response - WebSocket Cookie Response 54 55=head1 SYNOPSIS 56 57 # Constructor 58 my $cookie = Protocol::WebSocket::Cookie::Response->new( 59 name => 'foo', 60 value => 'bar', 61 discard => 1, 62 max_age => 0 63 ); 64 $cookie->to_string; # foo=bar; Discard; Max-Age=0; Version=1 65 66 # Parser 67 my $cookie = Protocol::WebSocket::Cookie::Response->new; 68 $cookie->parse('foo=bar; Discard; Max-Age=0; Version=1'); 69 70=head1 DESCRIPTION 71 72Construct or parse a WebSocket response cookie. 73 74=head1 METHODS 75 76=head2 C<parse> 77 78Parse a WebSocket response cookie. 79 80=head2 C<to_string> 81 82Construct a WebSocket response cookie. 83 84=cut 85