adjust netlib.wsgi to reflect changes in mitmproxys flow format

This commit is contained in:
Maximilian Hils 2014-02-05 21:34:14 +01:00
parent 0bbc40dc33
commit 7fc544bc7f
3 changed files with 12 additions and 6 deletions

View File

@ -178,7 +178,7 @@ class Address(object):
This class wraps an IPv4/IPv6 tuple to provide named attributes and ipv6 information.
"""
def __init__(self, address, use_ipv6=False):
self.address = address
self.address = tuple(address)
self.use_ipv6 = use_ipv6
@classmethod

View File

@ -1,17 +1,22 @@
import cStringIO, urllib, time, traceback
import odict
import odict, tcp
class ClientConn:
def __init__(self, address):
self.address = address
self.address = tcp.Address.wrap(address)
class Flow:
def __init__(self, client_conn):
self.client_conn = client_conn
class Request:
def __init__(self, client_conn, scheme, method, path, headers, content):
self.scheme, self.method, self.path = scheme, method, path
self.headers, self.content = headers, content
self.client_conn = client_conn
self.flow = Flow(client_conn)
def date_time_string():
@ -60,8 +65,8 @@ class WSGIAdaptor:
'SERVER_PROTOCOL': "HTTP/1.1",
}
environ.update(extra)
if request.client_conn.address:
environ["REMOTE_ADDR"], environ["REMOTE_PORT"] = request.client_conn.address
if request.flow.client_conn.address:
environ["REMOTE_ADDR"], environ["REMOTE_PORT"] = request.flow.client_conn.address()
for key, value in request.headers.items():
key = 'HTTP_' + key.upper().replace('-', '_')

View File

@ -215,6 +215,7 @@ class TestSNI(test.ServerTestBase):
c = tcp.TCPClient(("127.0.0.1", self.port))
c.connect()
c.convert_to_ssl(sni="foo.com")
assert c.sni == "foo.com"
assert c.rfile.readline() == "foo.com"