Skip to content
This repository
Browse code

request.host works with IPv6 addresses. Closes #9458.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7382 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 33e5e41ddaf59bc9c08e4d9eb34d52174bf05114 1 parent 55efae2
Jeremy Kemper authored August 31, 2007
2  actionpack/CHANGELOG
... ...
@@ -1,5 +1,7 @@
1 1
 *SVN*
2 2
 
  3
+* request.host works with IPv6 addresses.  #9458 [yuya]
  4
+
3 5
 * Fix bug where action caching sets the content type to the ActionCachePath object.  Closes #9282 [mindforge]
4 6
 
5 7
 * Find layouts even if they're not in the first view_paths directory.  Closes #9258 [caio]
2  actionpack/lib/action_controller/cgi_process.rb
@@ -92,7 +92,7 @@ def host_with_port
92 92
     end
93 93
 
94 94
     def host
95  
-      host_with_port[/^[^:]+/]
  95
+      host_with_port.sub(/:\d+$/, '')
96 96
     end
97 97
 
98 98
     def port
12  actionpack/test/controller/cgi_test.rb
@@ -47,6 +47,18 @@ def test_host_with_port_falls_back_to_server_addr_if_necessary
47 47
     assert_equal "207.7.108.53:8007", @request.host_with_port
48 48
   end
49 49
 
  50
+  def test_host_if_ipv6_reference
  51
+    @request_hash.delete "HTTP_X_FORWARDED_HOST"
  52
+    @request_hash['HTTP_HOST'] = "[2001:1234:5678:9abc:def0::dead:beef]"
  53
+    assert_equal "[2001:1234:5678:9abc:def0::dead:beef]", @request.host
  54
+  end
  55
+
  56
+  def test_host_if_ipv6_reference_with_port
  57
+    @request_hash.delete "HTTP_X_FORWARDED_HOST"
  58
+    @request_hash['HTTP_HOST'] = "[2001:1234:5678:9abc:def0::dead:beef]:8008"
  59
+    assert_equal "[2001:1234:5678:9abc:def0::dead:beef]", @request.host
  60
+  end
  61
+
50 62
   def test_cookie_syntax_resilience
51 63
     cookies = CGI::Cookie::parse(@request_hash["HTTP_COOKIE"]);
52 64
     assert_equal ["c84ace84796670c052c6ceb2451fb0f2"], cookies["_session_id"]

0 notes on commit 33e5e41

Please sign in to comment.
Something went wrong with that request. Please try again.