permessage_deflate 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1df768e3e9548d14e1de4aa42cb436ba26ed8dcd
4
- data.tar.gz: 5200b1ad6bd6b0c52f437ca19078897e5f172221
3
+ metadata.gz: a14c8dd2a4f9ba707ef04843ddf38f63edab8a96
4
+ data.tar.gz: a5ae9bc81616693639e4c3bc119c9e0f56fba26e
5
5
  SHA512:
6
- metadata.gz: 507ca2039b829e07107eca9ccf5bfaa6c751f69bbcb7a3a26b433b90ec6e37f6af7ff75c043ac7e79b129abc23df55117cd1248fc02468be49363528ce634081
7
- data.tar.gz: fa119c3394b0e2297e10f373a1f6afee3c47c391e07b7c7881e5662a628d87c57baeb9e7ca5f5bd631d000e1962b829a428871f408fed2dbb12269031a86969f
6
+ metadata.gz: 3a652f56d83877215d70642b93fa2d06903e5dbdf1696cc73a397ffa6614864a71d82ec5b4d0f5cdb5854930e166dfe0f24da605137b1e70acac10fd533fcc32
7
+ data.tar.gz: 3c7d27e351764c4f6c19ced876ba6a8664b638ac0aef40ce8290a03412d628164723b49b277582887eb9aa0aeca6fdfa7fb4e11c73730c194ac6a576c5d0d407
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.1.2 / 2015-11-06
2
+
3
+ * The server does not send `server_max_window_bits` if the client does not ask
4
+ for it; this works around an issue in Firefox.
5
+
1
6
  ### 0.1.1 / 2014-12-18
2
7
 
3
8
  * Don't allow configure() to be called with unrecognized options
data/README.md CHANGED
@@ -70,22 +70,21 @@ can be used to set the local session's behaviour and control that of the peer:
70
70
 
71
71
  (The MIT License)
72
72
 
73
- Copyright (c) 2014 James Coglan
73
+ Copyright (c) 2014-2015 James Coglan
74
74
 
75
75
  Permission is hereby granted, free of charge, to any person obtaining a copy of
76
76
  this software and associated documentation files (the 'Software'), to deal in
77
77
  the Software without restriction, including without limitation the rights to
78
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
79
- of the Software, and to permit persons to whom the Software is furnished to do
80
- so, subject to the following conditions:
78
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
79
+ the Software, and to permit persons to whom the Software is furnished to do so,
80
+ subject to the following conditions:
81
81
 
82
82
  The above copyright notice and this permission notice shall be included in all
83
83
  copies or substantial portions of the Software.
84
84
 
85
85
  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
86
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
87
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
88
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
89
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
90
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
91
- SOFTWARE.
86
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
87
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
88
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
89
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
90
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -59,12 +59,12 @@ class PermessageDeflate
59
59
 
60
60
  @own_context_takeover = !(@accept_no_context_takeover || params['client_no_context_takeover'])
61
61
  @own_window_bits = [
62
- @accept_max_window_bits || DEFAULT_MAX_WINDOW_BITS,
63
- params['client_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
62
+ @accept_max_window_bits || MAX_WINDOW_BITS,
63
+ params['client_max_window_bits'] || MAX_WINDOW_BITS
64
64
  ].min
65
65
 
66
66
  @peer_context_takeover = !params['server_no_context_takeover']
67
- @peer_window_bits = params['server_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
67
+ @peer_window_bits = params['server_max_window_bits'] || MAX_WINDOW_BITS
68
68
 
69
69
  true
70
70
  end
@@ -17,42 +17,48 @@ class PermessageDeflate
17
17
  end
18
18
 
19
19
  def generate_response
20
- params = {}
20
+ response = {}
21
21
 
22
22
  # https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.1.1
23
- if @accept_no_context_takeover or @params['server_no_context_takeover']
24
- params['server_no_context_takeover'] = true
25
- end
23
+
24
+ @own_context_takeover = !@accept_no_context_takeover &&
25
+ !@params['server_no_context_takeover']
26
+
27
+ response['server_no_context_takeover'] = true unless @own_context_takeover
26
28
 
27
29
  # https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.1.2
28
- if @request_no_context_takeover or @params['client_no_context_takeover']
29
- params['client_no_context_takeover'] = true
30
- end
30
+
31
+ @peer_context_takeover = !@request_no_context_takeover &&
32
+ !@params['client_no_context_takeover']
33
+
34
+ response['client_no_context_takeover'] = true unless @peer_context_takeover
31
35
 
32
36
  # https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.2.1
33
- if @accept_max_window_bits or @params['server_max_window_bits']
34
- accept_max = @accept_max_window_bits || DEFAULT_MAX_WINDOW_BITS
35
- server_max = @params['server_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
36
- params['server_max_window_bits'] = [accept_max, server_max].min
37
+
38
+ @own_window_bits = [ @accept_max_window_bits || MAX_WINDOW_BITS,
39
+ @params['server_max_window_bits'] || MAX_WINDOW_BITS
40
+ ].min
41
+
42
+ # In violation of the spec, Firefox closes the connection if it does not
43
+ # send server_max_window_bits but the server includes this in its response
44
+ if @own_window_bits < MAX_WINDOW_BITS and @params['server_max_window_bits']
45
+ response['server_max_window_bits'] = @own_window_bits
37
46
  end
38
47
 
39
48
  # https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.2.2
49
+
40
50
  if client_max = @params['client_max_window_bits']
41
- if client_max == true
42
- params['client_max_window_bits'] = @request_max_window_bits if @request_max_window_bits
43
- else
44
- request_max = @request_max_window_bits || DEFAULT_MAX_WINDOW_BITS
45
- params['client_max_window_bits'] = [request_max, client_max].min
46
- end
51
+ client_max = MAX_WINDOW_BITS if client_max == true
52
+ @peer_window_bits = [@request_max_window_bits || MAX_WINDOW_BITS, client_max].min
53
+ else
54
+ @peer_window_bits = MAX_WINDOW_BITS
47
55
  end
48
56
 
49
- @own_context_takeover = !params['server_no_context_takeover']
50
- @own_window_bits = params['server_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
51
-
52
- @peer_context_takeover = !params['client_no_context_takeover']
53
- @peer_window_bits = params['client_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
57
+ if @peer_window_bits < MAX_WINDOW_BITS
58
+ response['client_max_window_bits'] = @peer_window_bits
59
+ end
54
60
 
55
- params
61
+ response
56
62
  end
57
63
 
58
64
  end
@@ -8,7 +8,7 @@ class PermessageDeflate
8
8
  'client_max_window_bits'
9
9
  ]
10
10
 
11
- DEFAULT_MAX_WINDOW_BITS = 15
11
+ MAX_WINDOW_BITS = 15
12
12
  VALID_WINDOW_BITS = [8, 9, 10, 11, 12, 13, 14, 15]
13
13
 
14
14
  def self.valid_params?(params)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: permessage_deflate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-18 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 2.2.2
64
+ rubygems_version: 2.4.5.1
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Per-message DEFLATE compression extension for WebSocket connections