Class: BrowserTestChannel::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/browser_test_channel.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Server

Returns a new instance of Server.



21
22
23
24
25
26
27
28
29
# File 'lib/browser_test_channel.rb', line 21

def initialize options={}
  @options = {
    # alternate host prefix for clients with connection pool limits
    :host_prefix => nil,
    # network admins can block this host to disable streaming
    # '/mail/images/cleardot.gif' must be found on this host
    :blocked_prefix => nil,
  }.merge! options
end

Instance Method Details

#call(env) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/browser_test_channel.rb', line 30

def call env
  request = Rack::Request.new env
  if request.GET['MODE'] == 'init'
    [
      200,
      {'Content-Type' => 'application/javascript'}, 
      [[@options[:host_prefix], @options[:blocked_prefix]].to_json]
    ]
  else
    BrowserTestChannel.new request
    Thin::Connection::AsyncResponse
  end
end