Skip to content
Open
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
4 changes: 4 additions & 0 deletions lib/thin/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def pre_process
if @backend.ssl?
@request.env["rack.url_scheme"] = "https"

if @backend.respond_to?(:port)
@request.env['SERVER_PORT'] = @backend.port.to_s
end

if cert = get_peer_cert
@request.env['rack.peer_cert'] = cert
end
Expand Down
10 changes: 9 additions & 1 deletion spec/connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
expect(@connection.remote_address).to eq("127.0.0.1")
end

it "should return nil on error retreiving remote_address" do
it "should return nil on error retrieving remote_address" do
allow(@connection).to receive(:get_peername).and_raise(RuntimeError)
expect(@connection.remote_address).to be_nil
end
Expand Down Expand Up @@ -143,4 +143,12 @@
it "should not set as threaded when app do not respond to deferred?" do
expect(@connection).not_to be_threaded
end

it "should have correct SERVER_PORT when using ssl" do
@connection.backend = double("backend", :ssl? => true, :port => 443)

@connection.process

expect(@connection.request.env["SERVER_PORT"]).to eq("443")
end
end