Sha256: 96458430a3a6f8041eb7fe9f11b878fdc689e20985a92cf28d558793f8c5f0ce

Contents?: true

Size: 675 Bytes

Versions: 8

Compression:

Stored size: 675 Bytes

Contents

require 'webrick/httpproxy'

handler = proc { |_, res| res['X-PROXIED'] = true }

ProxyServer = WEBrick::HTTPProxyServer.new(
  :Port => 8080,
  :AccessLog => [],
  :RequestCallback => handler
)

AuthenticatedProxyServer = WEBrick::HTTPProxyServer.new(
  :Port => 8081,
  :ProxyAuthProc => proc do | req, res |
    WEBrick::HTTPAuth.proxy_basic_auth(req, res, 'proxy') do | user, pass |
      user == 'username' && pass == 'password'
    end
  end,
  :RequestCallback => handler
)

Thread.new  { ProxyServer.start }
trap('INT') do
  ProxyServer.shutdown
  exit
end

Thread.new  { AuthenticatedProxyServer.start }
trap('INT') do
  AuthenticatedProxyServer.shutdown
  exit
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
http-0.7.4 spec/support/proxy_server.rb
http-0.6.4 spec/support/proxy_server.rb
http-0.7.3 spec/support/proxy_server.rb
http-0.7.2 spec/support/proxy_server.rb
http-0.7.1 spec/support/proxy_server.rb
http-0.7.0 spec/support/proxy_server.rb
http-0.6.3 spec/support/proxy_server.rb
http-0.6.2 spec/support/proxy_server.rb