Skip to content

Commit ee8add0

Browse files
committed
Added function to add content type
1 parent 32d70ed commit ee8add0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

adafruit_portalbase/network.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ def __init__(
9696
self.json_transform = []
9797
self._extract_values = extract_values
9898

99-
self._json_types = (
99+
self._json_types = [
100100
"application/json",
101101
"application/javascript",
102102
"application/geo+json",
103-
)
103+
]
104104

105105
# This may be removed. Using for testing
106106
self.requests = None
@@ -433,6 +433,16 @@ def fetch(self, url, *, headers=None, timeout=10):
433433

434434
return response
435435

436+
def add_json_content_type(self, content_type):
437+
"""
438+
Add a JSON content type
439+
440+
:param str type: The content JSON type like 'application/json'
441+
442+
"""
443+
if isinstance(content_type, str):
444+
self._json_types.append(content_type)
445+
436446
def _detect_content_type(self, headers):
437447
if "content-type" in headers:
438448
if "image/" in headers["content-type"]:

0 commit comments

Comments
 (0)