Sha256: e7e794568f16052bf5216a8532660452157744017026a9667bf2938f9f8e9065

Contents?: true

Size: 841 Bytes

Versions: 7

Compression:

Stored size: 841 Bytes

Contents

A request/response rewriting HTTP proxy. A Rack app.

Subclass Rack::Proxy and provide your rewrite_env and rewrite_response methods.

Example:

class Foo < Rack::Proxy

  def rewrite_env(env)
    env["HTTP_HOST"] = "example.com"

    env
  end

  def rewrite_response(triplet)
    status, headers, body = triplet

    headers["X-Foo"] = "Bar"

    triplet
  end

end

Example: disable SSL session verification when proxying a server with e.g. self-signed SSL certs

class TrustingProxy < Rack::Proxy

  def rewrite_env(env)
    env["rack.ssl_verify_none"] = true

    env
  end

end

The same can be achieved for *all* requests going through the `Rack::Proxy` instance by using

    Rack::Proxy.new(ssl_verify_none: true)

See tests for more examples.

WARNING: Doesn't work with fakeweb/webmock. Both libraries monkey-patch net/http code.

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rack-proxy-0.5.14 Readme
rack-proxy-0.5.13 Readme
rack-proxy-0.5.12 Readme
rack-proxy-0.5.11 Readme
rack-proxy-0.5.10 Readme
rack-proxy-0.5.9 Readme
rack-proxy-0.5.8 Readme