line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::WebSocket::PMCE::deflate::Client; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
155606
|
use strict; |
|
2
|
|
|
|
|
22
|
|
|
2
|
|
|
|
|
60
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
72
|
|
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
|
|
|
|
|
13
|
use parent qw( |
65
|
|
|
|
|
|
|
Net::WebSocket::PMCE::deflate |
66
|
2
|
|
|
2
|
|
852
|
); |
|
2
|
|
|
|
|
625
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
use constant { |
69
|
2
|
|
|
|
|
716
|
_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
|
|
128
|
}; |
|
2
|
|
|
|
|
5
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _create_extension_header_parts { |
78
|
4
|
|
|
4
|
|
8
|
my ($self) = @_; |
79
|
|
|
|
|
|
|
|
80
|
4
|
|
|
|
|
13
|
my @parts = $self->SUPER::_create_extension_header_parts(); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#Let’s always advertise support for this feature. |
83
|
4
|
100
|
|
|
|
13
|
if (!defined $self->{'deflate_max_window_bits'}) { |
84
|
3
|
|
|
|
|
8
|
push @parts, _DEFLATE_MAX_WINDOW_BITS_PARAM() => undef; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
4
|
|
|
|
|
19
|
return @parts; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _consume_extension_options { |
91
|
6
|
|
|
6
|
|
13
|
my ($self, $opts_hr) = @_; |
92
|
|
|
|
|
|
|
|
93
|
6
|
100
|
|
|
|
19
|
if (exists $opts_hr->{'server_max_window_bits'}) { |
94
|
2
|
|
|
|
|
8
|
$self->__validate_max_window_bits('server', $opts_hr->{'server_max_window_bits'}); |
95
|
|
|
|
|
|
|
|
96
|
2
|
100
|
|
|
|
23
|
if ( $opts_hr->{'server_max_window_bits'} > $self->inflate_max_window_bits() ) { |
97
|
1
|
|
|
|
|
10
|
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
|
|
|
|
|
11
|
delete $opts_hr->{'server_max_window_bits'}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
5
|
100
|
|
|
|
13
|
if (exists $opts_hr->{'client_max_window_bits'}) { |
105
|
1
|
|
|
|
|
5
|
$self->__validate_max_window_bits('client', $opts_hr->{'client_max_window_bits'}); |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
4
|
my $max = $self->deflate_max_window_bits(); |
108
|
|
|
|
|
|
|
|
109
|
1
|
50
|
|
|
|
4
|
if ($opts_hr->{'client_max_window_bits'} < $max) { |
110
|
1
|
|
|
|
|
3
|
$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
|
|
|
|
|
3
|
delete $opts_hr->{'client_max_window_bits'}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
5
|
100
|
|
|
|
13
|
if (exists $opts_hr->{'client_no_context_takeover'}) { |
120
|
1
|
|
|
|
|
7
|
$self->__validate_no_context_takeover( $opts_hr->{'client_no_context_takeover'} ); |
121
|
|
|
|
|
|
|
|
122
|
1
|
|
|
|
|
3
|
$self->{'deflate_no_context_takeover'} = 1; |
123
|
|
|
|
|
|
|
|
124
|
1
|
|
|
|
|
3
|
delete $opts_hr->{'client_no_context_takeover'}; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
5
|
100
|
|
|
|
15
|
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
|
|
|
|
|
2
|
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
|
|
|
|
|
3
|
delete $self->{'inflate_no_context_takeover'}; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
5
|
|
|
|
|
10
|
return; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
1; |