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:
commit
76c21451b2
1 changed files with 9 additions and 8 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue