From 275cf7a6c2189859ad5f5719c8b74b1bc6eebbf2 Mon Sep 17 00:00:00 2001 From: Linmiao Xu Date: Wed, 6 Jul 2016 21:01:04 -0700 Subject: [PATCH] Detect JSON API media type as a json content view IANA assignment here: https://www.iana.org/assignments/media-types/application/vnd.api+json More about JSON API: https://github.com/json-api/json-api --- mitmproxy/contentviews.py | 5 ++++- test/mitmproxy/test_contentview.py | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index 6f64e360a..331a706f4 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -226,7 +226,10 @@ class ViewXML(View): class ViewJSON(View): name = "JSON" prompt = ("json", "s") - content_types = ["application/json"] + content_types = [ + "application/json", + "application/vnd.api+json" + ] def __call__(self, data, **metadata): pj = pretty_json(data) diff --git a/test/mitmproxy/test_contentview.py b/test/mitmproxy/test_contentview.py index 52fceeac0..c11a5fe52 100644 --- a/test/mitmproxy/test_contentview.py +++ b/test/mitmproxy/test_contentview.py @@ -201,6 +201,13 @@ Larry ) assert "Raw" in r[0] + r = cv.get_content_view( + cv.get("Auto"), + b"[1, 2, 3]", + headers=Headers(content_type="application/vnd.api+json") + ) + assert r[0] == "JSON" + tutils.raises( ContentViewException, cv.get_content_view,