Class: PermessageDeflate::ServerSession
- Defined in:
- lib/permessage_deflate/server_session.rb
Constant Summary
Constants inherited from Session
PermessageDeflate::Session::MAX_WINDOW_BITS, PermessageDeflate::Session::MIN_WINDOW_BITS, PermessageDeflate::Session::VALID_PARAMS, PermessageDeflate::Session::VALID_WINDOW_BITS
Class Method Summary collapse
Instance Method Summary collapse
- #generate_response ⇒ Object
-
#initialize(options, params) ⇒ ServerSession
constructor
A new instance of ServerSession.
Methods inherited from Session
#close, #process_incoming_message, #process_outgoing_message
Constructor Details
#initialize(options, params) ⇒ ServerSession
Returns a new instance of ServerSession.
14 15 16 17 |
# File 'lib/permessage_deflate/server_session.rb', line 14 def initialize(, params) super() @params = params end |
Class Method Details
.valid_params?(params) ⇒ Boolean
4 5 6 7 8 9 10 11 12 |
# File 'lib/permessage_deflate/server_session.rb', line 4 def self.valid_params?(params) return false unless super if params.has_key?('client_max_window_bits') return false unless ([true] + VALID_WINDOW_BITS).include?(params['client_max_window_bits']) end true end |
Instance Method Details
#generate_response ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/permessage_deflate/server_session.rb', line 19 def generate_response response = {} # 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/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/rfc7692#section-7.1.2.1 @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/rfc7692#section-7.1.2.2 if client_max = @params['client_max_window_bits'] 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 if @peer_window_bits < MAX_WINDOW_BITS response['client_max_window_bits'] = @peer_window_bits end response end |