Class: ForwardHost
- Inherits:
-
Rack::Proxy
- Object
- Rack::Proxy
- ForwardHost
- Defined in:
- lib/rack_proxy_examples/forward_host.rb
Constant Summary
Constants inherited from Rack::Proxy
Rack::Proxy::HOP_BY_HOP_HEADERS, Rack::Proxy::VERSION
Instance Method Summary collapse
Methods inherited from Rack::Proxy
build_header_hash, #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 |
# File 'lib/rack_proxy_examples/forward_host.rb', line 3 def rewrite_env(env) env["HTTP_HOST"] = "example.com" env end |
#rewrite_response(triplet) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rack_proxy_examples/forward_host.rb', line 8 def rewrite_response(triplet) status, headers, body = triplet # example of inserting an additional header headers["X-Foo"] = "Bar" # 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 |