Class: TrustingProxy

Inherits:
Rack::Proxy show all
Defined in:
lib/rack_proxy_examples/trusting_proxy.rb

Constant Summary

Constants inherited from Rack::Proxy

Rack::Proxy::VERSION

Instance Method Summary collapse

Methods inherited from Rack::Proxy

#call, extract_http_request_headers, #initialize, normalize_headers

Constructor Details

This class inherits a constructor from Rack::Proxy

Instance Method Details

#rewrite_env(env) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/rack_proxy_examples/trusting_proxy.rb', line 3

def rewrite_env(env)
  env["HTTP_HOST"] = "self-signed.badssl.com"

  # We are going to trust the self-signed SSL 
  env["rack.ssl_verify_none"] = true
  env
end

#rewrite_response(triplet) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/rack_proxy_examples/trusting_proxy.rb', line 11

def rewrite_response(triplet)
  status, headers, body = triplet
  
  # if you rewrite env, it appears that content-length isn't calculated correctly
  # resulting in only partial responses being sent to users
  # you can remove it or recalculate it here
  headers["content-length"] = nil

  triplet
end