class EmmyHttp::Server::Parser

Attributes

http_parser[RW]
no_body[RW]
stop[RW]

Public Class Methods

new() click to toggle source
# File lib/emmy_http/server/parser.rb, line 13
def initialize
  @http_parser = HTTP::Parser.new
  @http_parser.header_value_type = :mixed
  @http_parser.on_headers_complete = proc do
    head!(http_parser.headers, http_parser)
    stop ? :stop : (no_body ? :reset : nil)
  end
  @http_parser.on_body = proc do |chunk|
    body!(chunk)
  end
  @http_parser.on_message_complete = proc do
    complete!
  end
end

Public Instance Methods

<<(data) click to toggle source
# File lib/emmy_http/server/parser.rb, line 28
def <<(data)
  @http_parser << data
rescue HTTP::Parser::Error => e
  raise EmmyHttp::ParserError, e.to_s
end
headers() click to toggle source
# File lib/emmy_http/server/parser.rb, line 42
def headers
  @http_parser.headers
end
http_method() click to toggle source
# File lib/emmy_http/server/parser.rb, line 38
def http_method
  @http_parser.http_method
end
http_version() click to toggle source
# File lib/emmy_http/server/parser.rb, line 46
def http_version
  @http_parser.http_version
end
request_url() click to toggle source
# File lib/emmy_http/server/parser.rb, line 50
def request_url
  @http_parser.request_url
end
reset!() click to toggle source
# File lib/emmy_http/server/parser.rb, line 54
def reset!
  @http_parser.reset!
end
status_code() click to toggle source
# File lib/emmy_http/server/parser.rb, line 34
def status_code
  @http_parser.status_code
end