From bd2658f482b318762e37d8b0ddfe68b159c6e143 Mon Sep 17 00:00:00 2001 From: slootsky Date: Wed, 23 Dec 2020 17:14:14 -0500 Subject: [PATCH] added json_content-type parameter as per discussion at https://github.com/adafruit/Adafruit_CircuitPython_PortalBase/issues/3 --- adafruit_portalbase/network.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adafruit_portalbase/network.py b/adafruit_portalbase/network.py index 6665de8..43ed1f8 100755 --- a/adafruit_portalbase/network.py +++ b/adafruit_portalbase/network.py @@ -435,6 +435,7 @@ def fetch_data( json_path=None, regexp_path=None, timeout=10, + json_content_type=None, ): """Fetch data from the specified url and perfom any parsing @@ -444,7 +445,7 @@ def fetch_data( :param regexp_path: The path formatted as a regular expression to drill down into the JSON data. :param int timeout: The timeout period in seconds. - + :param json_content_type: A known value for content-type when JSON is returned """ json_out = None values = [] @@ -468,6 +469,8 @@ def fetch_data( content_type = CONTENT_JSON elif "application/javascript" in headers["content-type"]: content_type = CONTENT_JSON + elif json_content_type and json_content_type in headers["content-type"]: + content_type = CONTENT_JSON else: if self._debug: if "content-length" in headers: