mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Compare host and server name only once per call.
Backport of https://github.com/rack/rack/pull/1042
This commit is contained in:
parent
f5f23aaac7
commit
bb1833163d
1 changed files with 9 additions and 8 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue