diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-18 18:01:28 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-18 18:01:28 +0000 |
commit | 61960e7b37767140e9af68bd5373e06dce08492d (patch) | |
tree | c23a31b689a2470a6185198bd4ac065aefa61456 /actionpack/lib/action_controller | |
parent | a7532f9d5f47cf17c18a17dccff2a6d317d8254e (diff) | |
download | rails-61960e7b37767140e9af68bd5373e06dce08492d.tar.gz rails-61960e7b37767140e9af68bd5373e06dce08492d.tar.bz2 rails-61960e7b37767140e9af68bd5373e06dce08492d.zip |
Added Request#port_string to get something like ":8080" back on 8080 and "" on 80 (or 443 with https).
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@214 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 13 | ||||
-rw-r--r-- | actionpack/lib/action_controller/test_process.rb | 4 |
2 files changed, 10 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index e9ab3cad90..d3d65ec0ec 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -84,14 +84,13 @@ module ActionController env["SERVER_PORT"].to_i end + # Returns a string like ":8080" if the port is not 80 or 443 while on https. + def port_string + (protocol == "http://" && port == 80) || (protocol == "https://" && port == 443) ? "" : ":#{port}" + end + def host_with_port - if env['HTTP_HOST'] - env['HTTP_HOST'] - elsif (protocol == "http://" && port == 80) || (protocol == "https://" && port == 443) - host - else - host + ":#{port}" - end + env['HTTP_HOST'] || host + port_string end #-- diff --git a/actionpack/lib/action_controller/test_process.rb b/actionpack/lib/action_controller/test_process.rb index 3590d29cd3..b248626fa4 100644 --- a/actionpack/lib/action_controller/test_process.rb +++ b/actionpack/lib/action_controller/test_process.rb @@ -37,6 +37,10 @@ module ActionController #:nodoc: @cookies.freeze end + def port=(number) + @env["SERVER_PORT"] = number.to_i + end + def action=(action_name) @query_parameters.update({ "action" => action_name }) @parameters = nil |