Class: Rack::Request
- Inherits:
-
Object
- Object
- Rack::Request
- Defined in:
- lib/contour/fixes/rack.rb
Instance Method Summary collapse
Instance Method Details
#host_with_port ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/contour/fixes/rack.rb', line 21 def host_with_port if forwarded = @env["HTTP_X_FORWARDED_HOST"] Rails.logger.info "\n\nContour::Fixes => Rack::Request::host_with_port" Rails.logger.info "@env[HTTP_X_FORWARDED_HOST]: #{@env["HTTP_X_FORWARDED_HOST"]} USING => #{forwarded.split(/,\s?/).first}\n\n" # forwarded.split(/,\s?/).last # changed forwarded to first since we don't want the internal IP. forwarded.split(/,\s?/).first else @env['HTTP_HOST'] || "#{@env['SERVER_NAME'] || @env['SERVER_ADDR']}:#{@env['SERVER_PORT']}" end end |
#port ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/contour/fixes/rack.rb', line 33 def port if port = host_with_port.split(/:/)[1] port.to_i elsif port = @env['HTTP_X_FORWARDED_PORT'] port.to_i elsif ssl? 443 elsif @env.has_key?("HTTP_X_FORWARDED_HOST") 80 else @env["SERVER_PORT"].to_i end end |
#scheme ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/contour/fixes/rack.rb', line 4 def scheme # Rails.logger.debug "Contour::Fixes => Rack::Request::scheme" if @env['HTTPS'] == 'on' 'https' elsif @env['HTTP_X_FORWARDED_SSL'] == 'on' 'https' elsif @env['HTTP_X_FORWARDED_PROTO'] @env['HTTP_X_FORWARDED_PROTO'].split(',')[0] else @env["rack.url_scheme"] end end |
#ssl? ⇒ Boolean
17 18 19 |
# File 'lib/contour/fixes/rack.rb', line 17 def ssl? scheme == 'https' end |