line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::WebSocket::PMCE::deflate::Client; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
119610
|
use strict; |
|
2
|
|
|
|
|
19
|
|
|
2
|
|
|
|
|
43
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
63
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=encoding utf-8 |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::WebSocket::PMCE::deflate::Client - permessage-deflate for a client |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $deflate = Net::WebSocket::PMCE::deflate::Server->new( %opts ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#Send this to the server. |
17
|
|
|
|
|
|
|
my $handshake = $deflate->create_handshake_object(); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#You’ll probably want Net::WebSocket::Handshake |
20
|
|
|
|
|
|
|
#to do this for you, but just in case: |
21
|
|
|
|
|
|
|
#$deflate->consume_parameters( @params_kv ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#OPTIONAL: Inspect $deflate to be sure you’re happy with the setup |
24
|
|
|
|
|
|
|
#that the client’s parameters allow. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#...and now use this to send/receive messages. |
27
|
|
|
|
|
|
|
my $data_obj = $deflate->create_data_object(); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 DESCRIPTION |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
See L for general information about |
32
|
|
|
|
|
|
|
this class. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 I->consume_parameters( KEY1 => VALUE1, .. ) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Inherited from the base class. The alterations made in response |
39
|
|
|
|
|
|
|
to the different parameters are: |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=over |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * - Sets the object’s |
44
|
|
|
|
|
|
|
C flag. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * - If the object’s |
47
|
|
|
|
|
|
|
C flag is set, and if |
48
|
|
|
|
|
|
|
we do *not* receive this flag from the peer, then we C. |
49
|
|
|
|
|
|
|
This option is ignored otherwise. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item * - If given and less than the object’s |
52
|
|
|
|
|
|
|
C option, then that option is reduced to the |
53
|
|
|
|
|
|
|
new value. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item * - If given and less than the object’s |
56
|
|
|
|
|
|
|
C option, then that option is reduced to the |
57
|
|
|
|
|
|
|
new value. If given and B than the object’s |
58
|
|
|
|
|
|
|
C option, then we C. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=back |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
2
|
|
|
|
|
7
|
use parent qw( |
65
|
|
|
|
|
|
|
Net::WebSocket::PMCE::deflate |
66
|
2
|
|
|
2
|
|
668
|
); |
|
2
|
|
|
|
|
427
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use constant { |
69
|
2
|
|
|
|
|
539
|
_PEER_NO_CONTEXT_TAKEOVER_PARAM => 'server_no_context_takeover', |
70
|
|
|
|
|
|
|
_LOCAL_NO_CONTEXT_TAKEOVER_PARAM => 'client_no_context_takeover', |
71
|
|
|
|
|
|
|
_DEFLATE_MAX_WINDOW_BITS_PARAM => 'client_max_window_bits', |
72
|
|
|
|
|
|
|
_INFLATE_MAX_WINDOW_BITS_PARAM => 'server_max_window_bits', |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
_ENDPOINT_CLASS => 'Client', |
75
|
2
|
|
|
2
|
|
101
|
}; |
|
2
|
|
|
|
|
5
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _create_extension_header_parts { |
78
|
4
|
|
|
4
|
|
8
|
my ($self) = @_; |
79
|
|
|
|
|
|
|
|
80
|
4
|
|
|
|
|
14
|
my @parts = $self->SUPER::_create_extension_header_parts(); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#Let’s always advertise support for this feature. |
83
|
4
|
100
|
|
|
|
9
|
if (!defined $self->{'deflate_max_window_bits'}) { |
84
|
3
|
|
|
|
|
7
|
push @parts, _DEFLATE_MAX_WINDOW_BITS_PARAM() => undef; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
4
|
|
|
|
|
22
|
return @parts; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _consume_extension_options { |
91
|
6
|
|
|
6
|
|
10
|
my ($self, $opts_hr) = @_; |
92
|
|
|
|
|
|
|
|
93
|
6
|
100
|
|
|
|
13
|
if (exists $opts_hr->{'server_max_window_bits'}) { |
94
|
2
|
|
|
|
|
6
|
$self->__validate_max_window_bits('server', $opts_hr->{'server_max_window_bits'}); |
95
|
|
|
|
|
|
|
|
96
|
2
|
100
|
|
|
|
24
|
if ( $opts_hr->{'server_max_window_bits'} > $self->inflate_max_window_bits() ) { |
97
|
1
|
|
|
|
|
9
|
die 'server_max_window_bits greater than client stipulated!'; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
2
|
$self->{'inflate_max_window_bits'} = $opts_hr->{'server_max_window_bits'}; |
101
|
1
|
|
|
|
|
9
|
delete $opts_hr->{'server_max_window_bits'}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
5
|
100
|
|
|
|
11
|
if (exists $opts_hr->{'client_max_window_bits'}) { |
105
|
1
|
|
|
|
|
4
|
$self->__validate_max_window_bits('client', $opts_hr->{'client_max_window_bits'}); |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
3
|
my $max = $self->deflate_max_window_bits(); |
108
|
|
|
|
|
|
|
|
109
|
1
|
50
|
|
|
|
5
|
if ($opts_hr->{'client_max_window_bits'} < $max) { |
110
|
1
|
|
|
|
|
2
|
$self->{'deflate_max_window_bits'} = $opts_hr->{'client_max_window_bits'}; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#If the server requested a greater client_max_window_bits than |
114
|
|
|
|
|
|
|
#we gave, that’s no problem, but we’re just going to ignore it. |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
|
|
|
2
|
delete $opts_hr->{'client_max_window_bits'}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
5
|
100
|
|
|
|
10
|
if (exists $opts_hr->{'client_no_context_takeover'}) { |
120
|
1
|
|
|
|
|
5
|
$self->__validate_no_context_takeover( $opts_hr->{'client_no_context_takeover'} ); |
121
|
|
|
|
|
|
|
|
122
|
1
|
|
|
|
|
2
|
$self->{'deflate_no_context_takeover'} = 1; |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
2
|
delete $opts_hr->{'client_no_context_takeover'}; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
5
|
100
|
|
|
|
13
|
if (exists $opts_hr->{'server_no_context_takeover'}) { |
|
|
100
|
|
|
|
|
|
128
|
1
|
|
|
|
|
4
|
$self->__validate_no_context_takeover( $opts_hr->{'server_no_context_takeover'} ); |
129
|
1
|
|
|
|
|
3
|
delete $opts_hr->{'server_no_context_takeover'}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
elsif ($self->{'inflate_no_context_takeover'}) { |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
#The RFC doesn’t seem to have a problem with a server that |
134
|
|
|
|
|
|
|
#neglects a client’s server_no_context_takeover request. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
#die 'server didn’t accept server_no_context_takeover'; |
137
|
|
|
|
|
|
|
|
138
|
1
|
|
|
|
|
2
|
delete $self->{'inflate_no_context_takeover'}; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
5
|
|
|
|
|
9
|
return; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
1; |