Skip to content

Commit

Permalink
Fixed that ActionController::CgiRequest#host_with_port() should handl…
Browse files Browse the repository at this point in the history
…e standard port (closes #10082) [moro]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8088 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Nov 6, 2007
1 parent fdc767d commit 9a8d583
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Fixed that ActionController::CgiRequest#host_with_port() should handle standard port #10082 [moro]

* Update Prototype to 1.6.0 and script.aculo.us to 1.8.0. [sam, madrobby]

* Expose the cookie jar as a helper method (before the view would just get the raw cookie hash) [DHH]
Expand Down
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/cgi_process.rb
Expand Up @@ -82,7 +82,7 @@ def cookies
@cgi.cookies.freeze
end

def host_with_port
def host_with_port_without_standard_port_handling
if forwarded = env["HTTP_X_FORWARDED_HOST"]
forwarded.split(/,\s?/).last
elsif http_host = env['HTTP_HOST']
Expand All @@ -95,11 +95,11 @@ def host_with_port
end

def host
host_with_port.sub(/:\d+$/, '')
host_with_port_without_standard_port_handling.sub(/:\d+$/, '')
end

def port
if host_with_port =~ /:(\d+)$/
if host_with_port_without_standard_port_handling =~ /:(\d+)$/
$1.to_i
else
standard_port
Expand Down
11 changes: 11 additions & 0 deletions actionpack/test/controller/cgi_test.rb
Expand Up @@ -47,6 +47,17 @@ def test_host_with_port_falls_back_to_server_addr_if_necessary
assert_equal "207.7.108.53:8007", @request.host_with_port
end

def test_host_with_port_if_http_standard_port_is_specified
@request_hash['HTTP_X_FORWARDED_HOST'] = "glu.ttono.us:80"
assert_equal "glu.ttono.us", @request.host_with_port
end

def test_host_with_port_if_https_standard_port_is_specified
@request_hash['HTTP_X_FORWARDED_PROTO'] = "https"
@request_hash['HTTP_X_FORWARDED_HOST'] = "glu.ttono.us:443"
assert_equal "glu.ttono.us", @request.host_with_port
end

def test_host_if_ipv6_reference
@request_hash.delete "HTTP_X_FORWARDED_HOST"
@request_hash['HTTP_HOST'] = "[2001:1234:5678:9abc:def0::dead:beef]"
Expand Down
4 changes: 3 additions & 1 deletion railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Added --skip-timestamps to generators that produce models #10036 [tpope]

* Update Prototype to 1.6.0 and script.aculo.us to 1.8.0. [sam, madrobby]

* Added db:rollback to rollback the schema one version (or multiple as specified by STEP) [Jeffrey Allan Hardy]
Expand All @@ -25,9 +27,9 @@ databases on localhost. #9753 [Trevor Wennblom]

* Removed calls to fixtures in generated tests as fixtures :all is now present by default in test_helper.rb [DHH]


* Add --prefix option to script/server when using mongrel. [dacat]


*2.0.0 [Preview Release]* (September 29th, 2007) [Includes duplicates of changes from 1.1.4 - 1.2.3]

* Fixed that installing plugins from SVN repositories that use trunk/ will work #8188 [evan]
Expand Down

0 comments on commit 9a8d583

Please sign in to comment.