Sha256: 9325d7900c72a30f9e3c7071220294cd779852f02e0f0681061b9311ebe5caa6

Contents?: true

Size: 760 Bytes

Versions: 13

Compression:

Stored size: 760 Bytes

Contents

require 'rack/proxy'

# This only exists so we can use Rack::Test to test the
# RackAdapter class, which assumes it's running on Thin

class ThinProxy < Rack::Proxy
  HOST = 'localhost'
  PORT = '8282'
  
  def initialize(rack_app)
    Thin::Logging.silent = true
    handler = Rack::Handler.get('thin')
    
    EM.stop if EM.reactor_running?
    sleep 0.001 while EM.reactor_running?
    
    Thread.new {
      handler.run(rack_app, :Host => HOST, :Port => PORT) do |server|
        @server = server
      end
    }
    sleep 0.001 until EM.reactor_running?
  end
  
  def stop
    EM.stop
    @server.stop
    sleep 0.001 while EM.reactor_running?
  end
  
  def rewrite_env(env)
    env['HTTP_HOST'] = HOST
    env['SERVER_PORT'] = PORT
    env
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
faye-0.7.2 spec/thin_proxy.rb
faye-0.6.8 spec/thin_proxy.rb
faye-0.8.0 spec/thin_proxy.rb
faye-0.7.1 spec/thin_proxy.rb
faye-0.7.0 spec/thin_proxy.rb
faye-0.6.7 spec/thin_proxy.rb
faye-0.6.6 spec/thin_proxy.rb
faye-0.6.5 spec/thin_proxy.rb
faye-0.6.4 spec/thin_proxy.rb
faye-0.6.3 spec/thin_proxy.rb
faye-0.6.2 spec/thin_proxy.rb
faye-0.6.1 spec/thin_proxy.rb
faye-0.6.0 spec/thin_proxy.rb