Sha256: 40318a7733f05fcbddb8e202565189faacdc83f66760206112694cb23168f873

Contents?: true

Size: 819 Bytes

Versions: 10

Compression:

Stored size: 819 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?
    Thread.pass while EM.reactor_running?
    
    Thread.new {
      handler.run(rack_app, :Host => HOST, :Port => PORT) do |server|
        @server = server
      end
    }
    Thread.pass until EM.reactor_running?
  end
  
  def stop
    EM.stop
    @server.stop
    Thread.pass while EM.reactor_running?
  end
  
  def rewrite_env(env)
    env['HTTP_HOST'] = HOST
    env['SERVER_PORT'] = PORT
    env[Faye::RackAdapter::HTTP_X_NO_CONTENT_LENGTH] = '1'
    env
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
faye-0.8.8 spec/thin_proxy.rb
faye-0.8.6 spec/thin_proxy.rb
faye-0.8.5 spec/thin_proxy.rb
faye-0.8.4 spec/thin_proxy.rb
faye-0.8.3 spec/thin_proxy.rb
faye-0.8.2 spec/thin_proxy.rb
_bushido-faye-0.8.2 spec/thin_proxy.rb
_bushido-faye-0.8.1 spec/thin_proxy.rb
bushido-faye-0.8.1 spec/thin_proxy.rb
faye-0.8.1 spec/thin_proxy.rb