class HTTP::Response::Parser
Attributes
headers[R]
Public Class Methods
new()
click to toggle source
# File lib/http/response/parser.rb, line 6 def initialize @parser = HTTP::Parser.new(self) reset end
Public Instance Methods
add(data)
click to toggle source
# File lib/http/response/parser.rb, line 11 def add(data) @parser << data end
Also aliased as: <<
chunk()
click to toggle source
# File lib/http/response/parser.rb, line 44 def chunk chunk = @chunk @chunk = nil chunk end
finished?()
click to toggle source
# File lib/http/response/parser.rb, line 62 def finished? @finished end
headers?()
click to toggle source
# File lib/http/response/parser.rb, line 16 def headers? !!@headers end
http_version()
click to toggle source
# File lib/http/response/parser.rb, line 20 def http_version @parser.http_version.join(".") end
on_body(chunk)
click to toggle source
# File lib/http/response/parser.rb, line 36 def on_body(chunk) if @chunk @chunk << chunk else @chunk = chunk end end
on_headers_complete(headers)
click to toggle source
HTTP::Parser callbacks
# File lib/http/response/parser.rb, line 32 def on_headers_complete(headers) @headers = headers end
on_message_complete()
click to toggle source
# File lib/http/response/parser.rb, line 50 def on_message_complete @finished = true end
reset()
click to toggle source
# File lib/http/response/parser.rb, line 54 def reset @parser.reset! @finished = false @headers = nil @chunk = nil end
status_code()
click to toggle source
# File lib/http/response/parser.rb, line 24 def status_code @parser.status_code end