Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c1f34a9c6 | |||
| 610feed4c8 | |||
| 301f1876ea |
@@ -0,0 +1,7 @@
|
||||
### 0.1.1 / 2014-12-18
|
||||
|
||||
* Don't allow configure() to be called with unrecognized options
|
||||
|
||||
### 0.1.0 / 2014-12-13
|
||||
|
||||
* Initial release
|
||||
@@ -40,12 +40,12 @@ exts.add(deflate)
|
||||
|
||||
The set of available options can be split into two sets: those that control the
|
||||
session's compressor for outgoing messages and do not need to be communicated to
|
||||
the peer, and those that are negoatiated as part of the protocol. The settings
|
||||
the peer, and those that are negotiated as part of the protocol. The settings
|
||||
only affecting the compressor are described fully in the [Zlib
|
||||
documentation](http://ruby-doc.org/stdlib-2.1.0/libdoc/zlib/rdoc/Zlib/Deflate.html#method-c-new):
|
||||
|
||||
* `:level`: sets the compression level, can be an integer from `0` to `9`, or
|
||||
one of the contants `Zlib::NO_COMPRESSION`, `Zlib::BEST_SPEED`,
|
||||
one of the constants `Zlib::NO_COMPRESSION`, `Zlib::BEST_SPEED`,
|
||||
`Zlib::BEST_COMPRESSION`, or `Zlib::DEFAULT_COMPRESSION`
|
||||
* `:mem_level`: sets how much memory the compressor allocates, can be an integer
|
||||
from `1` to `9`, or one of the constants `Zlib::MAX_MEM_LEVEL`, or
|
||||
|
||||
@@ -8,6 +8,24 @@ class PermessageDeflate
|
||||
|
||||
ConfigurationError = Class.new(ArgumentError)
|
||||
|
||||
VALID_OPTIONS = [
|
||||
:level,
|
||||
:mem_level,
|
||||
:strategy,
|
||||
:no_context_takeover,
|
||||
:max_window_bits,
|
||||
:request_no_context_takeover,
|
||||
:request_max_window_bits
|
||||
]
|
||||
|
||||
def self.validate_options(options, valid_keys)
|
||||
options.keys.each do |key|
|
||||
unless valid_keys.include?(key)
|
||||
raise ConfigurationError, "Unrecognized option: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module Extension
|
||||
define_method(:name) { 'permessage-deflate' }
|
||||
define_method(:type) { 'permessage' }
|
||||
@@ -16,6 +34,7 @@ class PermessageDeflate
|
||||
define_method(:rsv3) { false }
|
||||
|
||||
def configure(options)
|
||||
PermessageDeflate.validate_options(options, VALID_OPTIONS)
|
||||
options = (@options || {}).merge(options)
|
||||
PermessageDeflate.new(options)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'permessage_deflate'
|
||||
s.version = '0.1.0'
|
||||
s.version = '0.1.1'
|
||||
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] + Dir.glob('lib/**/*.rb')
|
||||
s.files = %w[README.md CHANGELOG.md] + Dir.glob('lib/**/*.rb')
|
||||
|
||||
s.add_development_dependency 'rspec'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user