aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/request.rb
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2005-10-15 01:00:25 +0000
committerNicholas Seckar <nseckar@gmail.com>2005-10-15 01:00:25 +0000
commite0e8f0a3027f3777b961df9f9164d0bdd2fc0fbd (patch)
tree969f515f768cc0caf7537501c557dafd290fe7f4 /actionpack/lib/action_controller/request.rb
parent70869931611667d5b732ae91704313115e4baa10 (diff)
downloadrails-e0e8f0a3027f3777b961df9f9164d0bdd2fc0fbd.tar.gz
rails-e0e8f0a3027f3777b961df9f9164d0bdd2fc0fbd.tar.bz2
rails-e0e8f0a3027f3777b961df9f9164d0bdd2fc0fbd.zip
Fix Request#host_with_port to use the standard port when Rails is behind a proxy.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2596 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/request.rb')
-rwxr-xr-xactionpack/lib/action_controller/request.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index e5dc424476..aace415943 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -174,17 +174,25 @@ module ActionController
def port
@port_as_int ||= env['SERVER_PORT'].to_i
end
+
+ # Returns the standard port number for this request's protocol
+ def standard_port
+ case protocol
+ when 'https://' then 443
+ else 80
+ end
+ end
# Returns a port suffix like ":8080" if the port number of this request
# is not the default HTTP port 80 or HTTPS port 443.
def port_string
- (protocol == 'http://' && port == 80) || (protocol == 'https://' && port == 443) ? '' : ":#{port}"
+ (port == standard_port) ? '' : ":#{port}"
end
# Returns a host:port string for this request, such as example.com or
# example.com:8080.
def host_with_port
- env['HTTP_HOST'] || host + port_string
+ host + port_string
end
def path_parameters=(parameters)