Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/protocol/rack/adapter/rack2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ def make_environment(request)

# I'm not sure what sane defaults should be here:
CGI::SERVER_NAME => server_name,
CGI::SERVER_PORT => server_port,
}

# SERVER_PORT is optional but must not be set if it is not present.
if server_port
env[CGI::SERVER_PORT] = server_port
end

self.unwrap_request(request, env)

Expand Down
6 changes: 5 additions & 1 deletion lib/protocol/rack/adapter/rack3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ def make_environment(request)

# I'm not sure what sane defaults should be here:
CGI::SERVER_NAME => server_name,
CGI::SERVER_PORT => server_port,
}

# SERVER_PORT is optional but must not be set if it is not present.
if server_port
env[CGI::SERVER_PORT] = server_port
end

self.unwrap_request(request, env)

Expand Down
6 changes: 5 additions & 1 deletion lib/protocol/rack/adapter/rack31.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ def make_environment(request)

# I'm not sure what sane defaults should be here:
CGI::SERVER_NAME => server_name,
CGI::SERVER_PORT => server_port,
}

# SERVER_PORT is optional but must not be set if it is not present.
if server_port
env[CGI::SERVER_PORT] = server_port
end

if body = request.body
if body.empty?
Expand Down
12 changes: 12 additions & 0 deletions test/protocol/rack/adapter/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
expect(env).to have_keys("CONTENT_TYPE" => be == "text/plain")
end
end

with "app server without SERVER_PORT" do
let(:request) do
Protocol::HTTP::Request.new("https", "example.com", "GET", "/", "http/1.1", Protocol::HTTP::Headers[{"accept" => "text/html"}], nil)
end

it "does not include SERVER_PORT in the Rack environment" do
env = adapter.make_environment(request)

expect(env).not.to have_keys(Protocol::Rack::CGI::SERVER_PORT)
end
end

with "a app that returns nil" do
include DisableConsoleContext
Expand Down
Loading