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)
path = env['PATH_INFO']
script_name = env['SCRIPT_NAME']
hHost = env['HTTP_HOST']
sName = env['SERVER_NAME']
sPort = env['SERVER_PORT']
http_host = env['HTTP_HOST']
server_name = env['SERVER_NAME']
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|
unless casecmp?(hHost, host) \
|| casecmp?(sName, host) \
|| (!host && (casecmp?(hHost, sName) ||
casecmp?(hHost, sName+':'+sPort)))
unless casecmp?(http_host, host) \
|| casecmp?(server_name, host) \
|| (!host && is_same_server)
next
end
@ -87,4 +89,3 @@ module Puma::Rack
end
end
end