Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bbef7fbbcb | |||
| d5238e2837 | |||
| 8cc90986cf | |||
| 7737036691 | |||
| 0fc8ea74db | |||
| efb40b3b8e | |||
| c24da157a0 |
+7
-3
@@ -1,10 +1,14 @@
|
||||
sudo: false
|
||||
language: ruby
|
||||
|
||||
rvm:
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
- 2.1.3
|
||||
- 2.1.7
|
||||
- 2.2.3
|
||||
- jruby-19mode
|
||||
- rbx-2.2
|
||||
- jruby-9
|
||||
- rbx-2.5
|
||||
|
||||
script: bundle exec rspec -c spec/
|
||||
script:
|
||||
- bundle exec rspec -c spec
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
### 0.1.2 / 2015-11-06
|
||||
|
||||
* The server does not send `server_max_window_bits` if the client does not ask
|
||||
for it; this works around an issue in Firefox.
|
||||
|
||||
### 0.1.1 / 2014-12-18
|
||||
|
||||
* Don't allow configure() to be called with unrecognized options
|
||||
|
||||
@@ -70,22 +70,21 @@ can be used to set the local session's behaviour and control that of the peer:
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 James Coglan
|
||||
Copyright (c) 2014-2015 James Coglan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the 'Software'), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@@ -59,12 +59,12 @@ class PermessageDeflate
|
||||
|
||||
@own_context_takeover = !(@accept_no_context_takeover || params['client_no_context_takeover'])
|
||||
@own_window_bits = [
|
||||
@accept_max_window_bits || DEFAULT_MAX_WINDOW_BITS,
|
||||
params['client_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
|
||||
@accept_max_window_bits || MAX_WINDOW_BITS,
|
||||
params['client_max_window_bits'] || MAX_WINDOW_BITS
|
||||
].min
|
||||
|
||||
@peer_context_takeover = !params['server_no_context_takeover']
|
||||
@peer_window_bits = params['server_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
|
||||
@peer_window_bits = params['server_max_window_bits'] || MAX_WINDOW_BITS
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
@@ -17,42 +17,48 @@ class PermessageDeflate
|
||||
end
|
||||
|
||||
def generate_response
|
||||
params = {}
|
||||
response = {}
|
||||
|
||||
# https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.1.1
|
||||
if @accept_no_context_takeover or @params['server_no_context_takeover']
|
||||
params['server_no_context_takeover'] = true
|
||||
end
|
||||
|
||||
@own_context_takeover = !@accept_no_context_takeover &&
|
||||
!@params['server_no_context_takeover']
|
||||
|
||||
response['server_no_context_takeover'] = true unless @own_context_takeover
|
||||
|
||||
# https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.1.2
|
||||
if @request_no_context_takeover or @params['client_no_context_takeover']
|
||||
params['client_no_context_takeover'] = true
|
||||
end
|
||||
|
||||
@peer_context_takeover = !@request_no_context_takeover &&
|
||||
!@params['client_no_context_takeover']
|
||||
|
||||
response['client_no_context_takeover'] = true unless @peer_context_takeover
|
||||
|
||||
# https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.2.1
|
||||
if @accept_max_window_bits or @params['server_max_window_bits']
|
||||
accept_max = @accept_max_window_bits || DEFAULT_MAX_WINDOW_BITS
|
||||
server_max = @params['server_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
|
||||
params['server_max_window_bits'] = [accept_max, server_max].min
|
||||
|
||||
@own_window_bits = [ @accept_max_window_bits || MAX_WINDOW_BITS,
|
||||
@params['server_max_window_bits'] || MAX_WINDOW_BITS
|
||||
].min
|
||||
|
||||
# In violation of the spec, Firefox closes the connection if it does not
|
||||
# send server_max_window_bits but the server includes this in its response
|
||||
if @own_window_bits < MAX_WINDOW_BITS and @params['server_max_window_bits']
|
||||
response['server_max_window_bits'] = @own_window_bits
|
||||
end
|
||||
|
||||
# https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.2.2
|
||||
|
||||
if client_max = @params['client_max_window_bits']
|
||||
if client_max == true
|
||||
params['client_max_window_bits'] = @request_max_window_bits if @request_max_window_bits
|
||||
else
|
||||
request_max = @request_max_window_bits || DEFAULT_MAX_WINDOW_BITS
|
||||
params['client_max_window_bits'] = [request_max, client_max].min
|
||||
end
|
||||
client_max = MAX_WINDOW_BITS if client_max == true
|
||||
@peer_window_bits = [@request_max_window_bits || MAX_WINDOW_BITS, client_max].min
|
||||
else
|
||||
@peer_window_bits = MAX_WINDOW_BITS
|
||||
end
|
||||
|
||||
@own_context_takeover = !params['server_no_context_takeover']
|
||||
@own_window_bits = params['server_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
|
||||
if @peer_window_bits < MAX_WINDOW_BITS
|
||||
response['client_max_window_bits'] = @peer_window_bits
|
||||
end
|
||||
|
||||
@peer_context_takeover = !params['client_no_context_takeover']
|
||||
@peer_window_bits = params['client_max_window_bits'] || DEFAULT_MAX_WINDOW_BITS
|
||||
|
||||
params
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class PermessageDeflate
|
||||
'client_max_window_bits'
|
||||
]
|
||||
|
||||
DEFAULT_MAX_WINDOW_BITS = 15
|
||||
MAX_WINDOW_BITS = 15
|
||||
VALID_WINDOW_BITS = [8, 9, 10, 11, 12, 13, 14, 15]
|
||||
|
||||
def self.valid_params?(params)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'permessage_deflate'
|
||||
s.version = '0.1.1'
|
||||
s.version = '0.1.2'
|
||||
s.summary = 'Per-message DEFLATE compression extension for WebSocket connections'
|
||||
s.author = 'James Coglan'
|
||||
s.email = 'jcoglan@gmail.com'
|
||||
|
||||
@@ -163,8 +163,8 @@ describe PermessageDeflate::ServerSession do
|
||||
before { options[:max_window_bits] = 12 }
|
||||
|
||||
describe "with an empty offer" do
|
||||
it "includes server_max_window_bits in the response" do
|
||||
expect(response).to eq("server_max_window_bits" => 12)
|
||||
it "does not include server_max_window_bits in the response" do
|
||||
expect(response).to eq({})
|
||||
end
|
||||
|
||||
it "uses context takeover and 12 window bits for deflating outgoing messages" do
|
||||
|
||||
Reference in New Issue
Block a user