mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-26 18:18:25 +00:00
Make WSGI apps work in transparent mode.
This commit is contained in:
parent
79af9e89c4
commit
04d9ec8c3c
@ -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:
|
||||||
|
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user