Skip to content

added json_content_type parameter as per discussion at https://github… #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion adafruit_portalbase/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 = []
Expand All @@ -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:
Expand Down