Make WSGI apps work in transparent mode.

This commit is contained in:
Aldo Cortesi 2012-07-10 15:53:53 +12:00
parent 79af9e89c4
commit 04d9ec8c3c
2 changed files with 13 additions and 1 deletions

View File

@ -423,7 +423,11 @@ class AppRegistry:
""" """
Returns an WSGIAdaptor instance if request matches an app, or None. Returns an WSGIAdaptor instance if request matches an app, or None.
""" """
return self.apps.get((request.host, request.port), None) if (request.host, request.port) in self.apps:
return self.apps[(request.host, request.port)]
if "host" in request.headers:
host = request.headers["host"][0]
return self.apps.get((host, request.port), None)
class DummyServer: class DummyServer:

View File

@ -21,3 +21,11 @@ def test_app_registry():
r.port = 81 r.port = 81
assert not ar.get(r) assert not ar.get(r)
r = tutils.treq()
r.host = "domain2"
r.port = 80
assert not ar.get(r)
r.headers["host"] = ["domain"]
assert ar.get(r)