diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2014-01-05 10:57:50 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2014-01-05 10:57:50 +1300 |
commit | 5717e7300c1cc4a17f0fb0659dcf591fbd0a6e40 (patch) | |
tree | 38545320419f3ff9be6e6eb5a7c03a01ba5304d7 /netlib/wsgi.py | |
parent | c7606ffdf9ef1f94a5e065c1cce2241f60dcb81e (diff) | |
download | mitmproxy-5717e7300c1cc4a17f0fb0659dcf591fbd0a6e40.tar.gz mitmproxy-5717e7300c1cc4a17f0fb0659dcf591fbd0a6e40.tar.bz2 mitmproxy-5717e7300c1cc4a17f0fb0659dcf591fbd0a6e40.zip |
Make it possible to pass custom environment variables into wsgi apps.
Diffstat (limited to 'netlib/wsgi.py')
-rw-r--r-- | netlib/wsgi.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/netlib/wsgi.py b/netlib/wsgi.py index dffc2ace..647cb899 100644 --- a/netlib/wsgi.py +++ b/netlib/wsgi.py @@ -33,7 +33,7 @@ class WSGIAdaptor: def __init__(self, app, domain, port, sversion): self.app, self.domain, self.port, self.sversion = app, domain, port, sversion - def make_environ(self, request, errsoc): + def make_environ(self, request, errsoc, **extra): if '?' in request.path: path_info, query = request.path.split('?', 1) else: @@ -59,6 +59,7 @@ class WSGIAdaptor: # FIXME: We need to pick up the protocol read from the request. 'SERVER_PROTOCOL': "HTTP/1.1", } + environ.update(extra) if request.client_conn.address: environ["REMOTE_ADDR"], environ["REMOTE_PORT"] = request.client_conn.address @@ -86,7 +87,7 @@ class WSGIAdaptor: soc.write("\r\n") soc.write(c) - def serve(self, request, soc): + def serve(self, request, soc, **env): state = dict( response_started = False, headers_sent = False, @@ -123,7 +124,7 @@ class WSGIAdaptor: errs = cStringIO.StringIO() try: - dataiter = self.app(self.make_environ(request, errs), start_response) + dataiter = self.app(self.make_environ(request, errs, **env), start_response) for i in dataiter: write(i) if not state["headers_sent"]: |