From 775703e1f9b99500ecc362fd0eef5212b3580619 Mon Sep 17 00:00:00 2001 From: Tom Kadwill Date: Thu, 12 May 2016 07:05:41 +0100 Subject: Document and test ActionDispatch server_port --- actionpack/lib/action_dispatch/http/url.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'actionpack/lib/action_dispatch/http/url.rb') diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index b7a6aeee7d..7a1350a46d 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -354,6 +354,17 @@ module ActionDispatch standard_port? ? '' : ":#{port}" end + # Returns the requested port, such as 8080, based on SERVER_PORT + # + # class Request < Rack::Request + # include ActionDispatch::Http::URL + # end + # + # req = Request.new 'SERVER_PORT' => '80' + # req.server_port # => 80 + # + # req = Request.new 'SERVER_PORT' => '8080' + # req.server_port # => 8080 def server_port get_header('SERVER_PORT').to_i end -- cgit v1.2.3