class HTTP::Response::Parser
Attributes
headers[R]
Public Class Methods
new()
click to toggle source
# File lib/http/response/parser.rb, line 7 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 12 def add(data) @parser << data end
Also aliased as: <<
chunk()
click to toggle source
# File lib/http/response/parser.rb, line 45 def chunk chunk = @chunk @chunk = nil chunk end
finished?()
click to toggle source
# File lib/http/response/parser.rb, line 63 def finished? @finished end
headers?()
click to toggle source
# File lib/http/response/parser.rb, line 17 def headers? !!@headers end
http_version()
click to toggle source
# File lib/http/response/parser.rb, line 21 def http_version @parser.http_version.join(".") end
on_body(chunk)
click to toggle source
# File lib/http/response/parser.rb, line 37 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 33 def on_headers_complete(headers) @headers = headers end
on_message_complete()
click to toggle source
# File lib/http/response/parser.rb, line 51 def on_message_complete @finished = true end
reset()
click to toggle source
# File lib/http/response/parser.rb, line 55 def reset @parser.reset! @finished = false @headers = nil @chunk = nil end
status_code()
click to toggle source
# File lib/http/response/parser.rb, line 25 def status_code @parser.status_code end