Class: WebSocket::ServerHandshake
- Inherits:
-
Object
- Object
- WebSocket::ServerHandshake
- Defined in:
- lib/websocket/server_handshake.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#initialize(headers = {}) ⇒ ServerHandshake
constructor
A new instance of ServerHandshake.
- #render(out) ⇒ Object
- #to_data ⇒ Object
Constructor Details
#initialize(headers = {}) ⇒ ServerHandshake
Returns a new instance of ServerHandshake.
5 6 7 |
# File 'lib/websocket/server_handshake.rb', line 5 def initialize(headers = {}) @headers = headers end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
3 4 5 |
# File 'lib/websocket/server_handshake.rb', line 3 def headers @headers end |
Instance Method Details
#render(out) ⇒ Object
9 10 11 |
# File 'lib/websocket/server_handshake.rb', line 9 def render(out) out << to_data end |
#to_data ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/websocket/server_handshake.rb', line 13 def to_data data = "HTTP/1.1 101 Switching Protocols#{CRLF}" unless @headers.empty? data << @headers.map do |header, value| "#{header}: #{value}" end.join(CRLF) << CRLF end data << CRLF data end |