Skip to content

Commit

Permalink
Fix: HTTP_HOST header was getting a trailing ':' appended when no por…
Browse files Browse the repository at this point in the history
…t was specified.
  • Loading branch information
ihoka authored and brynary committed May 30, 2010
1 parent 6890e3b commit 2caed94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rack/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def env_for(path, env)
uri.path = "/#{uri.path}" unless uri.path[0] == ?/
uri.host ||= @default_host

env["HTTP_HOST"] = "#{uri.host}:#{uri.port}"
env["HTTP_HOST"] = [uri.host, uri.port].compact.join(":")

env = default_env.merge(env)

Expand Down
11 changes: 8 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ def check(*args)
yielded.should be_true
end

it "sets the HTTP host" do
send(verb, "http://example.com:80/uri")
last_request.env["HTTP_HOST"].should == "example.com:80"
it "sets the HTTP_HOST header with port" do
send(verb, "http://example.org:8080/uri")
last_request.env["HTTP_HOST"].should == "example.org:8080"
end

it "sets the HTTP_HOST header without port" do
send(verb, "/uri")
last_request.env["HTTP_HOST"].should == "example.org"
end

context "for a XHR" do
Expand Down

0 comments on commit 2caed94

Please sign in to comment.