Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1cb01d1304 | |||
| e0e7a26511 | |||
| 2e9ad522d1 | |||
| 966f48a980 | |||
| f88d2aa918 | |||
| 673dae1dda | |||
| 81702d4162 | |||
| 8c072d0d65 | |||
| 33223453a2 |
+6
-3
@@ -5,11 +5,14 @@ rvm:
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
- 2.1.10
|
||||
- 2.2.5
|
||||
- 2.3.1
|
||||
- 2.2.7
|
||||
- 2.3.4
|
||||
- 2.4.1
|
||||
- jruby-19mode
|
||||
- jruby-9
|
||||
- rbx-2
|
||||
|
||||
before_install:
|
||||
- '[[ "$(ruby --version)" == *"1.9.3"* ]] && gem update --system 2.4.8 || true'
|
||||
|
||||
script:
|
||||
- bundle exec rspec -c spec
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
### 0.1.4 / 2017-09-10
|
||||
|
||||
* Use `9` instead of `8` as the `windowBits` parameter to zlib, to deal with
|
||||
restrictions introduced in zlib v1.2.9
|
||||
|
||||
### 0.1.3 / 2016-05-20
|
||||
|
||||
* Amend all warnings issued when running with -W2
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
# The MIT License
|
||||
|
||||
Copyright (c) 2014-2017 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:
|
||||
|
||||
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.
|
||||
|
||||
@@ -11,7 +11,7 @@ WebSocket protocol extension as a plugin for
|
||||
$ gem install permessage_deflate
|
||||
```
|
||||
|
||||
## Usage
|
||||
## Usage
|
||||
|
||||
Add the plugin to your extensions:
|
||||
|
||||
@@ -65,26 +65,3 @@ can be used to set the local session's behaviour and control that of the peer:
|
||||
if requested by the peer
|
||||
* `:request_max_window_bits`: an integer from `8` to `15` inclusive to ask the
|
||||
other peer to use to set its maximum sliding window size, if supported
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014-2016 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:
|
||||
|
||||
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.
|
||||
|
||||
@@ -19,21 +19,21 @@ class PermessageDeflate
|
||||
def generate_response
|
||||
response = {}
|
||||
|
||||
# https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.1.1
|
||||
# https://tools.ietf.org/html/rfc7692#section-7.1.1.1
|
||||
|
||||
@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
|
||||
# https://tools.ietf.org/html/rfc7692#section-7.1.1.2
|
||||
|
||||
@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
|
||||
# https://tools.ietf.org/html/rfc7692#section-7.1.2.1
|
||||
|
||||
@own_window_bits = [ @accept_max_window_bits || MAX_WINDOW_BITS,
|
||||
@params['server_max_window_bits'] || MAX_WINDOW_BITS
|
||||
@@ -45,7 +45,7 @@ class PermessageDeflate
|
||||
response['server_max_window_bits'] = @own_window_bits
|
||||
end
|
||||
|
||||
# https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression#section-8.1.2.2
|
||||
# https://tools.ietf.org/html/rfc7692#section-7.1.2.2
|
||||
|
||||
if client_max = @params['client_max_window_bits']
|
||||
client_max = MAX_WINDOW_BITS if client_max == true
|
||||
|
||||
@@ -8,6 +8,7 @@ class PermessageDeflate
|
||||
'client_max_window_bits'
|
||||
]
|
||||
|
||||
MIN_WINDOW_BITS = 9
|
||||
MAX_WINDOW_BITS = 15
|
||||
VALID_WINDOW_BITS = [8, 9, 10, 11, 12, 13, 14, 15]
|
||||
|
||||
@@ -83,14 +84,20 @@ class PermessageDeflate
|
||||
|
||||
def get_inflate
|
||||
return @inflate if @inflate
|
||||
inflate = Zlib::Inflate.new(-@peer_window_bits)
|
||||
|
||||
window_bits = [@peer_window_bits, MIN_WINDOW_BITS].max
|
||||
inflate = Zlib::Inflate.new(-window_bits)
|
||||
|
||||
@inflate = inflate if @peer_context_takeover
|
||||
inflate
|
||||
end
|
||||
|
||||
def get_deflate
|
||||
return @deflate if @deflate
|
||||
deflate = Zlib::Deflate.new(@level, -@own_window_bits, @mem_level, @strategy)
|
||||
|
||||
window_bits = [@own_window_bits, MIN_WINDOW_BITS].max
|
||||
deflate = Zlib::Deflate.new(@level, -window_bits, @mem_level, @strategy)
|
||||
|
||||
@deflate = deflate if @own_context_takeover
|
||||
deflate
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'permessage_deflate'
|
||||
s.version = '0.1.3'
|
||||
s.version = '0.1.4'
|
||||
s.summary = 'Per-message DEFLATE compression extension for WebSocket connections'
|
||||
s.author = 'James Coglan'
|
||||
s.email = 'jcoglan@gmail.com'
|
||||
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
||||
s.rdoc_options = %w[--main README.md --markup markdown]
|
||||
s.require_paths = %w[lib]
|
||||
|
||||
s.files = %w[README.md CHANGELOG.md] + Dir.glob('lib/**/*.rb')
|
||||
s.files = %w[CHANGELOG.md LICENSE.md README.md] + Dir.glob('lib/**/*.rb')
|
||||
|
||||
s.add_development_dependency 'rspec'
|
||||
end
|
||||
|
||||
@@ -90,9 +90,9 @@ describe PermessageDeflate::ClientSession do
|
||||
expect(activate).to be true
|
||||
end
|
||||
|
||||
it "uses context takeover and 8 window bits for inflating incoming messages" do
|
||||
it "uses context takeover and 9 window bits for inflating incoming messages" do
|
||||
activate
|
||||
expect(Zlib::Inflate).to receive(:new).with(-8).exactly(1).and_return(inflate)
|
||||
expect(Zlib::Inflate).to receive(:new).with(-9).exactly(1).and_return(inflate)
|
||||
process_incoming_message
|
||||
process_incoming_message
|
||||
end
|
||||
@@ -113,9 +113,9 @@ describe PermessageDeflate::ClientSession do
|
||||
expect(activate).to be true
|
||||
end
|
||||
|
||||
it "uses context takeover and 8 window bits for deflating outgoing messages" do
|
||||
it "uses context takeover and 9 window bits for deflating outgoing messages" do
|
||||
activate
|
||||
expect(Zlib::Deflate).to receive(:new).with(level, -8, mem_level, strategy).exactly(1).and_return(deflate)
|
||||
expect(Zlib::Deflate).to receive(:new).with(level, -9, mem_level, strategy).exactly(1).and_return(deflate)
|
||||
process_outgoing_message
|
||||
process_outgoing_message
|
||||
end
|
||||
@@ -191,9 +191,9 @@ describe PermessageDeflate::ClientSession do
|
||||
expect(activate).to be true
|
||||
end
|
||||
|
||||
it "uses context takeover and 8 window bits for deflating outgoing messages" do
|
||||
it "uses context takeover and 9 window bits for deflating outgoing messages" do
|
||||
activate
|
||||
expect(Zlib::Deflate).to receive(:new).with(level, -8, mem_level, strategy).exactly(1).and_return(deflate)
|
||||
expect(Zlib::Deflate).to receive(:new).with(level, -9, mem_level, strategy).exactly(1).and_return(deflate)
|
||||
process_outgoing_message
|
||||
process_outgoing_message
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user