aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mitmproxy/contentviews.py2
-rw-r--r--mitmproxy/protocol/http2.py17
-rw-r--r--mitmproxy/protocol/rawtcp.py7
3 files changed, 14 insertions, 12 deletions
diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py
index 19f9b5f3..87cb2aa0 100644
--- a/mitmproxy/contentviews.py
+++ b/mitmproxy/contentviews.py
@@ -226,7 +226,7 @@ class ViewHTML(View):
content_types = ["text/html"]
def __call__(self, data, **metadata):
- if netlib.utils.isXML(data):
+ if mitmproxy.utils.isXML(data):
parser = lxml.etree.HTMLParser(
strip_cdata=True,
remove_blank_text=True
diff --git a/mitmproxy/protocol/http2.py b/mitmproxy/protocol/http2.py
index 9fc409a2..39512c8f 100644
--- a/mitmproxy/protocol/http2.py
+++ b/mitmproxy/protocol/http2.py
@@ -14,8 +14,9 @@ from six.moves import queue
import netlib.exceptions
from mitmproxy import exceptions
from mitmproxy import models
-from mitmproxy import protocol
-from netlib import http
+from mitmproxy.protocol import base
+from mitmproxy.protocol import http
+import netlib.http
from netlib import tcp
from netlib.http import http2
@@ -85,7 +86,7 @@ class SafeH2Connection(connection.H2Connection):
self.conn.send(self.data_to_send())
-class Http2Layer(protocol.base.Layer):
+class Http2Layer(base.Layer):
def __init__(self, ctx, mode):
super(Http2Layer, self).__init__(ctx)
@@ -132,12 +133,12 @@ class Http2Layer(protocol.base.Layer):
eid = event.stream_id
if isinstance(event, events.RequestReceived):
- headers = http.Headers([[k, v] for k, v in event.headers])
+ headers = netlib.http.Headers([[k, v] for k, v in event.headers])
self.streams[eid] = Http2SingleStreamLayer(self, eid, headers)
self.streams[eid].timestamp_start = time.time()
self.streams[eid].start()
elif isinstance(event, events.ResponseReceived):
- headers = http.Headers([[k, v] for k, v in event.headers])
+ headers = netlib.http.Headers([[k, v] for k, v in event.headers])
self.streams[eid].queued_data_length = 0
self.streams[eid].timestamp_start = time.time()
self.streams[eid].response_headers = headers
@@ -175,7 +176,7 @@ class Http2Layer(protocol.base.Layer):
self.client_conn.h2.push_stream(parent_eid, event.pushed_stream_id, event.headers)
self.client_conn.send(self.client_conn.h2.data_to_send())
- headers = http.Headers([[str(k), str(v)] for k, v in event.headers])
+ headers = netlib.http.Headers([[str(k), str(v)] for k, v in event.headers])
headers['x-mitmproxy-pushed'] = 'true'
self.streams[event.pushed_stream_id] = Http2SingleStreamLayer(self, event.pushed_stream_id, headers)
self.streams[event.pushed_stream_id].timestamp_start = time.time()
@@ -249,7 +250,7 @@ class Http2Layer(protocol.base.Layer):
self._cleanup_streams()
-class Http2SingleStreamLayer(protocol.http._HttpTransmissionLayer, threading.Thread):
+class Http2SingleStreamLayer(http._HttpTransmissionLayer, threading.Thread):
def __init__(self, ctx, stream_id, request_headers):
super(Http2SingleStreamLayer, self).__init__(ctx, name="Thread-Http2SingleStreamLayer-{}".format(stream_id))
@@ -444,7 +445,7 @@ class Http2SingleStreamLayer(protocol.http._HttpTransmissionLayer, threading.Thr
self()
def __call__(self):
- layer = protocol.http.HttpLayer(self, self.mode)
+ layer = http.HttpLayer(self, self.mode)
try:
layer()
diff --git a/mitmproxy/protocol/rawtcp.py b/mitmproxy/protocol/rawtcp.py
index 15f145e2..70486cc4 100644
--- a/mitmproxy/protocol/rawtcp.py
+++ b/mitmproxy/protocol/rawtcp.py
@@ -5,9 +5,10 @@ import socket
from OpenSSL import SSL
import netlib.exceptions
+import netlib.tcp
from mitmproxy import models
+from mitmproxy.models import tcp
from mitmproxy.protocol import base
-from netlib import tcp
class RawTCPLayer(base.Layer):
@@ -32,7 +33,7 @@ class RawTCPLayer(base.Layer):
try:
while not self.channel.should_exit.is_set():
- r = tcp.ssl_read_select(conns, 10)
+ r = netlib.tcp.ssl_read_select(conns, 10)
for conn in r:
dst = server if conn == client else client
@@ -51,7 +52,7 @@ class RawTCPLayer(base.Layer):
return
continue
- tcp_message = models.TCPMessage(dst == server, buf[:size].tobytes())
+ tcp_message = tcp.TCPMessage(dst == server, buf[:size].tobytes())
if not self.ignore:
flow.messages.append(tcp_message)
self.channel.ask("tcp_message", flow)