Skip to content

Commit

Permalink
Fix test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
cortesi committed Jun 1, 2016
1 parent d60fdeb commit 137ee28
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mitmproxy/contentviews.py
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions mitmproxy/protocol/http2.py
Expand Up @@ -14,8 +14,9 @@
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

Expand Down Expand Up @@ -85,7 +86,7 @@ def safe_send_body(self, is_zombie, stream_id, chunks):
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)
Expand Down Expand Up @@ -132,12 +133,12 @@ def _handle_event(self, event, source_conn, other_conn, is_server):
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
Expand Down Expand Up @@ -175,7 +176,7 @@ def _handle_event(self, event, source_conn, other_conn, is_server):
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()
Expand Down Expand Up @@ -249,7 +250,7 @@ def __call__(self):
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))
Expand Down Expand Up @@ -444,7 +445,7 @@ def run(self):
self()

def __call__(self):
layer = protocol.http.HttpLayer(self, self.mode)
layer = http.HttpLayer(self, self.mode)

try:
layer()
Expand Down
7 changes: 4 additions & 3 deletions mitmproxy/protocol/rawtcp.py
Expand Up @@ -5,9 +5,10 @@
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):
Expand All @@ -32,7 +33,7 @@ def __call__(self):

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

Expand All @@ -51,7 +52,7 @@ def __call__(self):
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)
Expand Down

0 comments on commit 137ee28

Please sign in to comment.