aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller')
-rwxr-xr-xactionpack/lib/action_controller/request.rb13
-rw-r--r--actionpack/lib/action_controller/test_process.rb4
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