diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-05-11 22:07:27 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-05-11 22:07:27 +0200 |
commit | 50ef6ed4500686826997688a622496bec9b0992a (patch) | |
tree | a4b6c061ad2d70de51defaa39d54c2ee7dc59044 /actionpack/lib | |
parent | 537a342a8307ebe1d5e69a7e81495f137ae571a4 (diff) | |
parent | 6b9bd2e3b08538cd74e497eb35193c51385f411e (diff) | |
download | rails-50ef6ed4500686826997688a622496bec9b0992a.tar.gz rails-50ef6ed4500686826997688a622496bec9b0992a.tar.bz2 rails-50ef6ed4500686826997688a622496bec9b0992a.zip |
Merge pull request #24982 from tomkadwill/improve_clarity_of_raw_host_with_port
Improve documentation and tests for raw_host_with_port and host_with_…
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/url.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index 37f41ae988..b7a6aeee7d 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -217,7 +217,7 @@ module ActionDispatch @protocol ||= ssl? ? 'https://' : 'http://' end - # Returns the \host for this request, such as "example.com". + # Returns the \host and port for this request, such as "example.com:8080". # # class Request < Rack::Request # include ActionDispatch::Http::URL @@ -226,6 +226,9 @@ module ActionDispatch # req = Request.new 'HTTP_HOST' => 'example.com' # req.raw_host_with_port # => "example.com" # + # req = Request.new 'HTTP_HOST' => 'example.com:80' + # req.raw_host_with_port # => "example.com:80" + # # req = Request.new 'HTTP_HOST' => 'example.com:8080' # req.raw_host_with_port # => "example.com:8080" def raw_host_with_port @@ -236,7 +239,7 @@ module ActionDispatch end end - # Returns the host for this request, such as example.com. + # Returns the host for this request, such as "example.com". # # class Request < Rack::Request # include ActionDispatch::Http::URL @@ -249,12 +252,16 @@ module ActionDispatch end # Returns a \host:\port string for this request, such as "example.com" or - # "example.com:8080". + # "example.com:8080". Port is only included if it is not a default port + # (80 or 443) # # class Request < Rack::Request # include ActionDispatch::Http::URL # end # + # req = Request.new 'HTTP_HOST' => 'example.com' + # req.host_with_port # => "example.com" + # # req = Request.new 'HTTP_HOST' => 'example.com:80' # req.host_with_port # => "example.com" # |