Replace `:compression` option with `:reset_accept_encoding`
The default is to now to not clear the `Accept-Encoding` header (this can be changed back to the older behavior by passing `reset_accept_encoding: true`)
This commit is contained in:
parent
5662cc2bde
commit
46eaa864b3
|
@ -65,14 +65,6 @@ If you'd like to bypass SSL verification
|
|||
reverse_proxy "http://localhost:8000", verify_ssl: false
|
||||
```
|
||||
|
||||
If you'd like to allow the proxy to request compressed resources by forwarding the `Accept-Encoding` header
|
||||
|
||||
```ruby
|
||||
reverse_proxy "http://localhost:8000", compression: :passthrough
|
||||
# Note that your controller's response will only be compressed
|
||||
# if the original response from localhost:8000 is compressed!
|
||||
```
|
||||
|
||||
If you'd like to customize the options passed into the [HTTP session](https://ruby-doc.org/stdlib-2.4.0/libdoc/net/http/rdoc/Net/HTTP.html#start-method)
|
||||
|
||||
```ruby
|
||||
|
|
|
@ -38,13 +38,13 @@ module ReverseProxy
|
|||
|
||||
def request(env, options = {}, &block)
|
||||
options.reverse_merge!(
|
||||
headers: {},
|
||||
http: {},
|
||||
path: nil,
|
||||
username: nil,
|
||||
password: nil,
|
||||
verify_ssl: true,
|
||||
compression: :disabled
|
||||
headers: {},
|
||||
http: {},
|
||||
path: nil,
|
||||
username: nil,
|
||||
password: nil,
|
||||
verify_ssl: true,
|
||||
reset_accept_encoding: false
|
||||
)
|
||||
|
||||
source_request = Rack::Request.new(env)
|
||||
|
@ -74,12 +74,9 @@ module ReverseProxy
|
|||
# Hold the response here
|
||||
target_response = nil
|
||||
|
||||
case options[:compression]
|
||||
when :passthrough
|
||||
# Pass along the "Accept-Encoding" header from the source request as-is,
|
||||
# so we don't need to change anything
|
||||
when :disabled, false, nil
|
||||
# Remove the "Accept-Encoding" header if compression is disabled
|
||||
if options[:reset_accept_encoding]
|
||||
# Clear the "Accept-Encoding" header (which will
|
||||
# disable compression or other server-side encodings)
|
||||
target_request['Accept-Encoding'] = nil
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue