Class: Lightstreamer::StreamConnectionHeader
- Inherits:
-
Object
- Object
- Lightstreamer::StreamConnectionHeader
- Defined in:
- lib/lightstreamer/stream_connection_header.rb
Overview
Helper class that processes the contents of the header returned by the server when a new stream connection is created or an existing session is bound to.
Instance Attribute Summary collapse
-
#error ⇒ ProtocolError, RequestError
readonly
If there was an error in the header then this value will be set to the error instance that should be raised in response.
Instance Method Summary collapse
-
#[](item_name) ⇒ String?
Returns the value for the item with the specified name in this header, or
nilif no item with the specified name was part of this header. -
#initialize ⇒ StreamConnectionHeader
constructor
A new instance of StreamConnectionHeader.
-
#process_header_line(line) ⇒ Boolean
Processes a single line of header information.
Constructor Details
#initialize ⇒ StreamConnectionHeader
Returns a new instance of StreamConnectionHeader.
9 10 11 12 |
# File 'lib/lightstreamer/stream_connection_header.rb', line 9 def initialize @data = {} @lines = [] end |
Instance Attribute Details
#error ⇒ ProtocolError, RequestError (readonly)
Returns If there was an error in the header then this value will be set to the error instance that should be raised in response.
7 8 9 |
# File 'lib/lightstreamer/stream_connection_header.rb', line 7 def error @error end |
Instance Method Details
#[](item_name) ⇒ String?
Returns the value for the item with the specified name in this header, or nil if no item with the specified name was part of this header
43 44 45 |
# File 'lib/lightstreamer/stream_connection_header.rb', line 43 def [](item_name) @data[item_name] end |
#process_header_line(line) ⇒ Boolean
Processes a single line of header information. The return value indicates whether further data is required in order to complete the header.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/lightstreamer/stream_connection_header.rb', line 20 def process_header_line(line) @lines << line unless %w(OK ERROR).include? @lines.first @error = RequestError.new line return false end return true if @lines.first == 'OK' && !line.empty? return true if @lines.first == 'ERROR' && @lines.size < 3 parse_header false end |