Module: Protocol::WebSocket::Extensions

Defined in:
lib/protocol/websocket/extensions.rb

Overview

Manages WebSocket extensions negotiated during the handshake.

Defined Under Namespace

Classes: Client, Server

Class Method Summary collapse

Class Method Details

.parse(headers) ⇒ Object

Parse a list of extension header values into name and argument pairs.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/protocol/websocket/extensions.rb', line 18

def self.parse(headers)
	return to_enum(:parse, headers) unless block_given?
	
	headers.each do |header|
		name, *arguments = header.split(/\s*;\s*/)
		
		arguments = arguments.map do |argument|
			argument.split("=", 2)
		end
		
		yield name, arguments
	end
end