1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Merge pull request #1091 from frodsan/cmp-host-server-once

Compare host and server name only once per call.
This commit is contained in:
Evan Phoenix 2016-09-17 14:05:59 -07:00 committed by GitHub
commit 76c21451b2

View file

@ -43,15 +43,17 @@ module Puma::Rack
def call(env) def call(env)
path = env['PATH_INFO'] path = env['PATH_INFO']
script_name = env['SCRIPT_NAME'] script_name = env['SCRIPT_NAME']
hHost = env['HTTP_HOST'] http_host = env['HTTP_HOST']
sName = env['SERVER_NAME'] server_name = env['SERVER_NAME']
sPort = env['SERVER_PORT'] server_port = env['SERVER_PORT']
is_same_server = casecmp?(http_host, server_name) ||
casecmp?(http_host, "#{server_name}:#{server_port}")
@mapping.each do |host, location, match, app| @mapping.each do |host, location, match, app|
unless casecmp?(hHost, host) \ unless casecmp?(http_host, host) \
|| casecmp?(sName, host) \ || casecmp?(server_name, host) \
|| (!host && (casecmp?(hHost, sName) || || (!host && is_same_server)
casecmp?(hHost, sName+':'+sPort)))
next next
end end
@ -87,4 +89,3 @@ module Puma::Rack
end end
end end
end end