Skip to content

Commit

Permalink
Request#env['SERVER_NAME'] does not contain port number
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Dec 28, 2008
1 parent c0c79f7 commit fec0ea9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def raw_host_with_port
if forwarded = env["HTTP_X_FORWARDED_HOST"]
forwarded.split(/,\s?/).last
else
env['HTTP_HOST'] || env['SERVER_NAME'] || "#{env['SERVER_ADDR']}:#{env['SERVER_PORT']}"
env['HTTP_HOST'] || "#{env['SERVER_NAME'] || env['SERVER_ADDR']}:#{env['SERVER_PORT']}"
end
end

Expand Down
6 changes: 1 addition & 5 deletions actionpack/lib/action_controller/test_process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ class TestRequest < Request #:nodoc:
attr_accessor :host

def initialize
env = Rack::MockRequest.env_for("/")

# TODO: Fix Request to assume env['SERVER_ADDR'] doesn't contain port number
env['SERVER_ADDR'] = env.delete("SERVER_NAME")
super(env)
super(Rack::MockRequest.env_for("/"))

@query_parameters = {}
@session = TestSession.new
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/controller/rack_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class BaseRackTest < Test::Unit::TestCase
def setup
@env = {
"HTTP_MAX_FORWARDS" => "10",
"SERVER_NAME" => "glu.ttono.us:8007",
"SERVER_NAME" => "glu.ttono.us",
"FCGI_ROLE" => "RESPONDER",
"AUTH_TYPE" => "Basic",
"HTTP_X_FORWARDED_HOST" => "glu.ttono.us",
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_cgi_environment_variables
assert_equal "kevin", @request.remote_user
assert_equal :get, @request.request_method
assert_equal "/dispatch.fcgi", @request.script_name
assert_equal "glu.ttono.us:8007", @request.server_name
assert_equal "glu.ttono.us", @request.server_name
assert_equal 8007, @request.server_port
assert_equal "HTTP/1.1", @request.server_protocol
assert_equal "lighttpd", @request.server_software
Expand Down

0 comments on commit fec0ea9

Please sign in to comment.