Module: Proxy::ActionController::AbstractRequest

Defined in:
lib/proxy/action_controller/abstract_request.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/proxy/action_controller/abstract_request.rb', line 4

def self.included(base)
  base.class_eval do
    mattr_accessor :forwarded_uri_header_name
    self.forwarded_uri_header_name = 'HTTP_X_FORWARDED_URI'
    memoize :forwarded_hosts, :forwarded_uris if respond_to? :memoize
  end
end

Instance Method Details

#forwarded_hostsObject

Parses the forwarded host header and returns an array of forwarded hosts

For example:

If the HTTP_X_FORWARDED_HOST header was set to 
  'some-domain.com, some-other-domain.com, and-another-domain.com'

This method would return [‘some-domain.com’, ‘some-other-domain.com’, ‘and-another-domain.com’]

Returns an empty array if there aren’t any forwarded hosts



22
23
24
# File 'lib/proxy/action_controller/abstract_request.rb', line 22

def forwarded_hosts
  env['HTTP_X_FORWARDED_HOST'].to_s.split(/,\s*/)
end

#forwarded_urisObject

Parses the forwarded uri header and returns an array of forwarded uris

For example:

If the HTTP_X_FORWARDED_URI header was set to 
  '/some/path, /some/other/path, /and/another/path'

This method would return [‘/some/path, ’/some/other/path’, ‘/and/another/path’]

Returns an empty array if there aren’t any forwarded uris



36
37
38
# File 'lib/proxy/action_controller/abstract_request.rb', line 36

def forwarded_uris
  env[self.forwarded_uri_header_name].to_s.split(/,\s*/)
end