Class: Firehose::Rack::Consumer::HttpLongPoll::Handler
- Inherits:
-
Object
- Object
- Firehose::Rack::Consumer::HttpLongPoll::Handler
- Includes:
- Helpers
- Defined in:
- lib/firehose/rack/consumer/http_long_poll.rb
Direct Known Subclasses
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(timeout = TIMEOUT) {|_self| ... } ⇒ Handler
constructor
A new instance of Handler.
Methods included from Helpers
Constructor Details
#initialize(timeout = TIMEOUT) {|_self| ... } ⇒ Handler
Returns a new instance of Handler.
29 30 31 32 |
# File 'lib/firehose/rack/consumer/http_long_poll.rb', line 29 def initialize(timeout=TIMEOUT) @timeout = timeout yield self if block_given? end |
Instance Method Details
#call(env) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/firehose/rack/consumer/http_long_poll.rb', line 34 def call(env) request = request(env) method = request.request_method case method # GET is how clients subscribe to the queue. When a messages comes in, we flush out a response, # close down the requeust, and the client then reconnects. when "GET" handle_request(request, env) return ASYNC_RESPONSE # we use post messages for http long poll multiplexing when "POST" if Consumer.multiplexing_request?(env) handle_request(request, env) return ASYNC_RESPONSE end end Firehose.logger.debug "HTTP #{method} not supported" response(405, "#{method} not supported.", "Allow" => "GET") end |