Sha256: 307938c23531af5c74bc2db2125a85a669cac45ead48136dfbd6f9af2870f8f4

Contents?: true

Size: 1.32 KB

Versions: 16

Compression:

Stored size: 1.32 KB

Contents

module Firehose
  module Rack
    autoload :Consumer,   'firehose/rack/consumer'
    autoload :Publisher,  'firehose/rack/publisher'
    autoload :Ping,       'firehose/rack/ping'
    autoload :App,        'firehose/rack/app'

    # Evented web servers recognize the -1 HTTP code as a response deferral, which
    # is needed to stream responses via WebSockets or HTTP long polling.
    ASYNC_RESPONSE = [-1, {}, []].freeze

    # Normally we'd want to use a custom header to reduce the likelihood of some
    # HTTP middleware clobbering the value. But Safari seems to ignore our CORS
    # header instructions, so we are using 'pragma' because it is always allowed.
    LAST_MESSAGE_SEQUENCE_HEADER = 'Pragma'

    # Rack wants the header to start with HTTP, so we deal with that here.
    RACK_LAST_MESSAGE_SEQUENCE_HEADER = "HTTP_#{LAST_MESSAGE_SEQUENCE_HEADER.upcase.gsub('-', '_')}"

    # Disable CORS preflight caches for requests in development mode.
    CORS_OPTIONS_MAX_AGE = ENV['RACK_ENV'] == 'development' ? '1' : '1728000'

    module Helpers
      # Calculates the content of a message body for the response so that HTTP Keep-Alive
      # connections work.
      def response(status, body='', headers={})
        headers = {'Content-Length' => body.size.to_s}.merge(headers)
        [status, headers, [body]]
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
firehose-1.3.6 lib/firehose/rack.rb
firehose-1.2.20 lib/firehose/rack.rb
firehose-1.2.13 lib/firehose/rack.rb
firehose-1.2.12 lib/firehose/rack.rb
firehose-1.2.11 lib/firehose/rack.rb
firehose-1.2.10 lib/firehose/rack.rb
firehose-1.2.9 lib/firehose/rack.rb
firehose-1.2.8 lib/firehose/rack.rb
firehose-1.2.7 lib/firehose/rack.rb
firehose-1.2.6 lib/firehose/rack.rb
firehose-1.2.5 lib/firehose/rack.rb
firehose-1.2.4 lib/firehose/rack.rb
firehose-1.2.3 lib/firehose/rack.rb
firehose-1.2.2 lib/firehose/rack.rb
firehose-1.2.1 lib/firehose/rack.rb
firehose-1.2.0 lib/firehose/rack.rb