diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py index 1e241deb5..af4dfc875 100644 --- a/mitmproxy/tools/web/app.py +++ b/mitmproxy/tools/web/app.py @@ -13,7 +13,7 @@ import tornado.web import tornado.websocket import mitmproxy.flow -import mitmproxy.tools.web.master # noqa +import mitmproxy.tools.web.master from mitmproxy import certs, command, contentviews from mitmproxy import flowfilter from mitmproxy import http @@ -21,7 +21,6 @@ from mitmproxy import io from mitmproxy import log from mitmproxy import optmanager from mitmproxy import version -from mitmproxy.addons import export from mitmproxy.http import HTTPFlow from mitmproxy.tcp import TCPFlow, TCPMessage from mitmproxy.tools.console.common import SYMBOL_MARK, render_marker @@ -533,7 +532,7 @@ class ExecuteCommand(RequestHandler): result = self.master.commands.call_strings(cmd, args) self.write({ "value": result, - "type": command.typename(type(result)) if result is not None else "none" + # "type": command.typename(type(result)) if result is not None else "none" }) @@ -621,7 +620,8 @@ class Application(tornado.web.Application): (r"/flows/(?P[0-9a-f\-]+)/revert", RevertFlow), (r"/flows/(?P[0-9a-f\-]+)/(?Prequest|response|messages)/content.data", FlowContent), ( - r"/flows/(?P[0-9a-f\-]+)/(?Prequest|response|messages)/content/(?P[0-9a-zA-Z\-\_%]+)(?:\.json)?", + r"/flows/(?P[0-9a-f\-]+)/(?Prequest|response|messages)/" + r"content/(?P[0-9a-zA-Z\-\_%]+)(?:\.json)?", FlowContentView), (r"/clear", ClearAll), (r"/options(?:\.json)?", Options), diff --git a/test/mitmproxy/contentviews/test_css.py b/test/mitmproxy/contentviews/test_css.py index 2479b4722..c69a7e80b 100644 --- a/test/mitmproxy/contentviews/test_css.py +++ b/test/mitmproxy/contentviews/test_css.py @@ -41,5 +41,5 @@ def test_simple(): def test_render_priority(): v = css.ViewCSS() - assert v.render_priority(b"", content_type="text/css") - assert not v.render_priority(b"", content_type="text/plain") + assert v.render_priority(b"data", content_type="text/css") + assert not v.render_priority(b"data", content_type="text/plain") diff --git a/test/mitmproxy/contentviews/test_javascript.py b/test/mitmproxy/contentviews/test_javascript.py index 823b7e12d..e16f9f376 100644 --- a/test/mitmproxy/contentviews/test_javascript.py +++ b/test/mitmproxy/contentviews/test_javascript.py @@ -31,7 +31,7 @@ def test_format_xml(filename, tdata): def test_render_priority(): v = javascript.ViewJavaScript() - assert v.render_priority(b"", content_type="application/x-javascript") - assert v.render_priority(b"", content_type="application/javascript") - assert v.render_priority(b"", content_type="text/javascript") - assert not v.render_priority(b"", content_type="text/plain") + assert v.render_priority(b"data", content_type="application/x-javascript") + assert v.render_priority(b"data", content_type="application/javascript") + assert v.render_priority(b"data", content_type="text/javascript") + assert not v.render_priority(b"data", content_type="text/plain") diff --git a/test/mitmproxy/contentviews/test_json.py b/test/mitmproxy/contentviews/test_json.py index ba14b5490..04bff0ea0 100644 --- a/test/mitmproxy/contentviews/test_json.py +++ b/test/mitmproxy/contentviews/test_json.py @@ -45,8 +45,8 @@ def test_view_json_doesnt_crash(data): def test_render_priority(): v = json.ViewJSON() - assert v.render_priority(b"", content_type="application/json") - assert v.render_priority(b"", content_type="application/json-rpc") - assert v.render_priority(b"", content_type="application/vnd.api+json") - assert v.render_priority(b"", content_type="application/acme+json") - assert not v.render_priority(b"", content_type="text/plain") + assert v.render_priority(b"data", content_type="application/json") + assert v.render_priority(b"data", content_type="application/json-rpc") + assert v.render_priority(b"data", content_type="application/vnd.api+json") + assert v.render_priority(b"data", content_type="application/acme+json") + assert not v.render_priority(b"data", content_type="text/plain") diff --git a/test/mitmproxy/contentviews/test_msgpack.py b/test/mitmproxy/contentviews/test_msgpack.py index cfc7e666c..ac97cd241 100644 --- a/test/mitmproxy/contentviews/test_msgpack.py +++ b/test/mitmproxy/contentviews/test_msgpack.py @@ -48,6 +48,6 @@ def test_view_msgpack_doesnt_crash(data): def test_render_priority(): v = msgpack.ViewMsgPack() - assert v.render_priority(b"", content_type="application/msgpack") - assert v.render_priority(b"", content_type="application/x-msgpack") - assert not v.render_priority(b"", content_type="text/plain") + assert v.render_priority(b"data", content_type="application/msgpack") + assert v.render_priority(b"data", content_type="application/x-msgpack") + assert not v.render_priority(b"data", content_type="text/plain") diff --git a/test/mitmproxy/contentviews/test_multipart.py b/test/mitmproxy/contentviews/test_multipart.py index 99b6042b5..da1f723e0 100644 --- a/test/mitmproxy/contentviews/test_multipart.py +++ b/test/mitmproxy/contentviews/test_multipart.py @@ -22,5 +22,5 @@ Larry def test_render_priority(): v = multipart.ViewMultipart() - assert v.render_priority(b"", content_type="multipart/form-data") - assert not v.render_priority(b"", content_type="text/plain") + assert v.render_priority(b"data", content_type="multipart/form-data") + assert not v.render_priority(b"data", content_type="text/plain") diff --git a/test/mitmproxy/contentviews/test_protobuf.py b/test/mitmproxy/contentviews/test_protobuf.py index 2fabf19af..962485496 100644 --- a/test/mitmproxy/contentviews/test_protobuf.py +++ b/test/mitmproxy/contentviews/test_protobuf.py @@ -32,6 +32,6 @@ def test_format_pbuf(filename, tdata): def test_render_priority(): v = protobuf.ViewProtobuf() - assert v.render_priority(b"", content_type="application/x-protobuf") - assert v.render_priority(b"", content_type="application/x-protobuffer") - assert not v.render_priority(b"", content_type="text/plain") + assert v.render_priority(b"data", content_type="application/x-protobuf") + assert v.render_priority(b"data", content_type="application/x-protobuffer") + assert not v.render_priority(b"data", content_type="text/plain") diff --git a/test/mitmproxy/contentviews/test_urlencoded.py b/test/mitmproxy/contentviews/test_urlencoded.py index 6c25fdd51..84c33dfce 100644 --- a/test/mitmproxy/contentviews/test_urlencoded.py +++ b/test/mitmproxy/contentviews/test_urlencoded.py @@ -17,5 +17,5 @@ def test_view_urlencoded(): def test_render_priority(): v = urlencoded.ViewURLEncoded() - assert v.render_priority(b"", content_type="application/x-www-form-urlencoded") - assert not v.render_priority(b"", content_type="text/plain") + assert v.render_priority(b"data", content_type="application/x-www-form-urlencoded") + assert not v.render_priority(b"data", content_type="text/plain") diff --git a/test/mitmproxy/contentviews/test_wbxml.py b/test/mitmproxy/contentviews/test_wbxml.py index 1497f41c6..f9a411145 100644 --- a/test/mitmproxy/contentviews/test_wbxml.py +++ b/test/mitmproxy/contentviews/test_wbxml.py @@ -22,6 +22,6 @@ def test_wbxml(tdata): def test_render_priority(): v = wbxml.ViewWBXML() - assert v.render_priority(b"", content_type="application/vnd.wap.wbxml") - assert v.render_priority(b"", content_type="application/vnd.ms-sync.wbxml") - assert not v.render_priority(b"", content_type="text/plain") + assert v.render_priority(b"data", content_type="application/vnd.wap.wbxml") + assert v.render_priority(b"data", content_type="application/vnd.ms-sync.wbxml") + assert not v.render_priority(b"data", content_type="text/plain") diff --git a/test/mitmproxy/contentviews/test_xml_html.py b/test/mitmproxy/contentviews/test_xml_html.py index 0f5c3983f..ec3e8905e 100644 --- a/test/mitmproxy/contentviews/test_xml_html.py +++ b/test/mitmproxy/contentviews/test_xml_html.py @@ -38,8 +38,8 @@ def test_format_xml(filename, tdata): def test_render_priority(): v = xml_html.ViewXmlHtml() - assert v.render_priority(b"", content_type="text/xml") - assert v.render_priority(b"", content_type="text/xml") - assert v.render_priority(b"", content_type="text/html") - assert not v.render_priority(b"", content_type="text/plain") + assert v.render_priority(b"data", content_type="text/xml") + assert v.render_priority(b"data", content_type="text/xml") + assert v.render_priority(b"data", content_type="text/html") + assert not v.render_priority(b"data", content_type="text/plain") assert v.render_priority(b"") diff --git a/test/mitmproxy/tools/web/test_app.py b/test/mitmproxy/tools/web/test_app.py index 15d71b901..3a2f97f73 100644 --- a/test/mitmproxy/tools/web/test_app.py +++ b/test/mitmproxy/tools/web/test_app.py @@ -14,14 +14,14 @@ import pytest from mitmproxy.http import Headers -import tornado.testing # noqa -from tornado import httpclient # noqa -from tornado import websocket # noqa +import tornado.testing +from tornado import httpclient +from tornado import websocket -from mitmproxy import options, optmanager # noqa -from mitmproxy.test import tflow # noqa -from mitmproxy.tools.web import app # noqa -from mitmproxy.tools.web import master as webmaster # noqa +from mitmproxy import options, optmanager +from mitmproxy.test import tflow +from mitmproxy.tools.web import app +from mitmproxy.tools.web import master as webmaster @pytest.fixture(scope="module") @@ -216,7 +216,9 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): ).headers["Content-Disposition"] == 'attachment; filename=bar.jpg' f.response.content = b"" - assert self.fetch("/flows/42/response/content.data").code == 400 + r = self.fetch("/flows/42/response/content.data") + assert r.code == 200 + assert r.body == b"" f.revert() @@ -268,7 +270,7 @@ class TestApp(tornado.testing.AsyncHTTPTestCase): assert resp.code == 500 resp = self.fetch("/commands/commands.history.get", method="POST") assert resp.code == 200 - assert get_json(resp) == ["unknown", "commands.history.get"] + assert get_json(resp) == {"value": []} def test_events(self): resp = self.fetch("/events")