Class: Celluloid::EventSource::ResponseParser

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/celluloid/eventsource/response_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponseParser

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

#headersObject (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

#chunkObject



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

Returns:

  • (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

#statusObject



24
25
26
# File 'lib/celluloid/eventsource/response_parser.rb', line 24

def status
  @parser.status_code
end