aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/request.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/request.rb')
-rwxr-xr-xactionpack/lib/action_controller/request.rb13
1 files changed, 6 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
#--