An HTTP Proxy server which proxies GET, HEAD and POST requests.

To create a simple proxy server:

require 'webrick'
require 'webrick/httpproxy'

proxy = Port: 8000

trap 'INT'  do proxy.shutdown end
trap 'TERM' do proxy.shutdown end


See ::new for proxy-specific configuration items.

Modifying proxied responses

To modify content the proxy server returns use the :ProxyContentHandler option:

handler = proc do |req, res|
  if res['content-type'] == 'text/plain' then
    res.body << "\nThis content was proxied!\n"

proxy = Port: 8000, ProxyContentHandler: handler
Show files where this class is defined (1 file)
Register or log in to add new notes.