File Coverage

blib/lib/Protocol/SPDY/Frame/Control/SYN_REPLY.pm
Criterion Covered Total %
statement 35 37 94.5
branch 1 2 50.0
condition 1 2 50.0
subroutine 9 10 90.0
pod 6 6 100.0
total 52 57 91.2


line stmt bran cond sub pod time code
1             package Protocol::SPDY::Frame::Control::SYN_REPLY;
2             {
3             $Protocol::SPDY::Frame::Control::SYN_REPLY::VERSION = '0.999_007';
4             }
5 3     3   10 use strict;
  3         4  
  3         71  
6 3     3   9 use warnings;
  3         3  
  3         64  
7 3     3   10 use parent qw(Protocol::SPDY::Frame::HeaderSupport Protocol::SPDY::Frame::Control);
  3         11  
  3         12  
8              
9             =head1 NAME
10              
11             Protocol::SPDY::Frame::Control::SYN_REPLY - response to a SYN_STREAM
12              
13             =head1 VERSION
14              
15             version 0.999_007
16              
17             =head1 SYNOPSIS
18              
19             =head1 DESCRIPTION
20              
21             See L and L.
22              
23             =cut
24              
25 3     3   200 use Protocol::SPDY::Constants ':all';
  3         3  
  3         1273  
26              
27             =head2 type_name
28              
29             The string type for this frame ('SYN_REPLY').
30              
31             =cut
32              
33 40     40 1 154 sub type_name { 'SYN_REPLY' }
34              
35             =head2 new
36              
37             Instantiate.
38              
39             =cut
40              
41             sub new {
42 14     14 1 17 my $class = shift;
43 14         48 my %args = @_;
44 14 50 50     60 $args{headers} = $class->header_hashref_to_arrayref($args{headers}) if (ref($args{headers}) || '') eq 'HASH';
45 14         74 $class->SUPER::new(%args)
46             }
47              
48             =head2 from_data
49              
50             Instantiate from the given data.
51              
52             =cut
53              
54             sub from_data {
55 8     8 1 16 my $class = shift;
56 8         29 my %args = @_;
57 8         40 my ($stream_id) = unpack "N1", substr $args{data}, 0, 4, '';
58 8         13 $stream_id &= ~0x80000000;
59 8         21 my $zlib = delete $args{zlib};
60 8         33 my $out = $zlib->decompress($args{data});
61 8         45 my ($headers) = $class->extract_headers($out);
62 8         37 $class->new(
63             %args,
64             stream_id => $stream_id,
65             headers => $headers,
66             );
67             }
68              
69             =head2 stream_id
70              
71             The stream ID we're responding to.
72              
73             =cut
74              
75 15     15 1 1601 sub stream_id { shift->{stream_id} }
76              
77             =head2 as_packet
78              
79             Returns the packet as a byte string.
80              
81             =cut
82              
83             sub as_packet {
84 7     7 1 13 my $self = shift;
85 7         8 my $zlib = shift;
86 7         20 my $payload = pack 'N1', $self->stream_id & 0x7FFFFFFF;
87 7         12 my $block = $self->pairs_to_nv_header(map {; $_->[0], join "\0", @{$_}[1..$#$_] } @{$self->headers});
  2         6  
  2         14  
  7         35  
88 7         28 $payload .= $zlib->compress($block);
89 7         34 return $self->SUPER::as_packet(
90             payload => $payload,
91             );
92             }
93              
94             =head2 to_string
95              
96             String representation, for debugging.
97              
98             =cut
99              
100             sub to_string {
101 0     0 1   my $self = shift;
102 0           $self->SUPER::to_string . ', ' . $self->header_line;
103             }
104              
105             1;
106              
107             __END__