Class: EmmyHttp::Server::Parser
- Inherits:
-
Object
- Object
- EmmyHttp::Server::Parser
- Defined in:
- lib/emmy_http/server/parser.rb
Instance Attribute Summary collapse
-
#http_parser ⇒ Object
Returns the value of attribute http_parser.
-
#no_body ⇒ Object
Returns the value of attribute no_body.
-
#stop ⇒ Object
Returns the value of attribute stop.
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #headers ⇒ Object
- #http_method ⇒ Object
- #http_version ⇒ Object
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #request_url ⇒ Object
- #reset! ⇒ Object
- #status_code ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# 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. = proc do complete! end end |
Instance Attribute Details
#http_parser ⇒ Object
Returns the value of attribute http_parser.
9 10 11 |
# File 'lib/emmy_http/server/parser.rb', line 9 def http_parser @http_parser end |
#no_body ⇒ Object
Returns the value of attribute no_body.
11 12 13 |
# File 'lib/emmy_http/server/parser.rb', line 11 def no_body @no_body end |
#stop ⇒ Object
Returns the value of attribute stop.
10 11 12 |
# File 'lib/emmy_http/server/parser.rb', line 10 def stop @stop end |
Instance Method Details
#<<(data) ⇒ Object
28 29 30 31 32 |
# 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 ⇒ Object
42 43 44 |
# File 'lib/emmy_http/server/parser.rb', line 42 def headers @http_parser.headers end |
#http_method ⇒ Object
38 39 40 |
# File 'lib/emmy_http/server/parser.rb', line 38 def http_method @http_parser.http_method end |
#http_version ⇒ Object
46 47 48 |
# File 'lib/emmy_http/server/parser.rb', line 46 def http_version @http_parser.http_version end |
#request_url ⇒ Object
50 51 52 |
# File 'lib/emmy_http/server/parser.rb', line 50 def request_url @http_parser.request_url end |
#reset! ⇒ Object
54 55 56 |
# File 'lib/emmy_http/server/parser.rb', line 54 def reset! @http_parser.reset! end |
#status_code ⇒ Object
34 35 36 |
# File 'lib/emmy_http/server/parser.rb', line 34 def status_code @http_parser.status_code end |