Class: Celluloid::EventSource::ResponseParser
- Inherits:
-
Object
- Object
- Celluloid::EventSource::ResponseParser
- Extended by:
- Forwardable
- Defined in:
- lib/celluloid/eventsource/response_parser.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
- #chunk ⇒ Object
- #headers? ⇒ Boolean
-
#initialize ⇒ ResponseParser
constructor
A new instance of ResponseParser.
- #on_body(chunk) ⇒ Object
- #on_headers_complete(headers) ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize ⇒ ResponseParser
Returns a new instance of ResponseParser.
14 15 16 17 18 |
# File 'lib/celluloid/eventsource/response_parser.rb', line 14 def initialize @parser = Http::Parser.new(self) @headers = nil @chunk = "" end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
10 11 12 |
# File 'lib/celluloid/eventsource/response_parser.rb', line 10 def headers @headers end |
Instance Method Details
#chunk ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/celluloid/eventsource/response_parser.rb', line 36 def chunk chunk = @chunk unless chunk.empty? @chunk = "" end chunk.to_s end |
#headers? ⇒ Boolean
20 21 22 |
# File 'lib/celluloid/eventsource/response_parser.rb', line 20 def headers? !!@headers end |
#on_body(chunk) ⇒ Object
32 33 34 |
# File 'lib/celluloid/eventsource/response_parser.rb', line 32 def on_body(chunk) @chunk << chunk end |
#on_headers_complete(headers) ⇒ Object
28 29 30 |
# File 'lib/celluloid/eventsource/response_parser.rb', line 28 def on_headers_complete(headers) @headers = canonical_headers(headers) end |
#status ⇒ Object
24 25 26 |
# File 'lib/celluloid/eventsource/response_parser.rb', line 24 def status @parser.status_code end |