Class: Yup::RequestHandler
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- Yup::RequestHandler
- Defined in:
- lib/yup/request_handler.rb
Instance Attribute Summary collapse
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
Instance Method Summary collapse
-
#initialize(forward_to, status_code, state, timeout) ⇒ RequestHandler
constructor
A new instance of RequestHandler.
- #on_body(chunk) ⇒ Object
- #on_message_begin ⇒ Object
- #on_message_complete ⇒ Object
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
Constructor Details
#initialize(forward_to, status_code, state, timeout) ⇒ RequestHandler
Returns a new instance of RequestHandler.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/yup/request_handler.rb', line 8 def initialize(forward_to, status_code, state, timeout) @forward_to = forward_to @status_code = status_code @state = state @timeout = timeout @chunks = [] @logger = Yup.logger.clone @logger.progname = "Yup::RequestHandler" end |
Instance Attribute Details
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
6 7 8 |
# File 'lib/yup/request_handler.rb', line 6 def queue @queue end |
Instance Method Details
#on_body(chunk) ⇒ Object
32 33 34 |
# File 'lib/yup/request_handler.rb', line 32 def on_body(chunk) @body << chunk end |
#on_message_begin ⇒ Object
28 29 30 |
# File 'lib/yup/request_handler.rb', line 28 def @body = '' end |
#on_message_complete ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/yup/request_handler.rb', line 36 def @logger.info { "Processing a new request: #{@parser.http_method} #{@parser.request_url} HTTP/#{@parser.http_version.join('.')}" } @logger.debug { "HTTP headers" + (@parser.headers.empty? ? " is empty" : "\n" + @parser.headers.inspect) } @logger.debug { "HTTP body" + (@body.empty? ? " is empty" : "\n" + @body) } send_answer shedule_request end |
#post_init ⇒ Object
20 21 22 |
# File 'lib/yup/request_handler.rb', line 20 def post_init @parser = Http::Parser.new(self) end |
#receive_data(data) ⇒ Object
24 25 26 |
# File 'lib/yup/request_handler.rb', line 24 def receive_data(data) @parser << data end |