diff options
| author | 2019-08-05 15:41:02 +0100 | |
|---|---|---|
| committer | 2019-08-05 15:41:02 +0100 | |
| commit | 20042edfd9b6e16b080f9abcbcdc9549c2107739 (patch) | |
| tree | c84b09aa9393923eaed7cb2d1f04a7d98a0f9c58 /src | |
| parent | Allow url shorteners to be specified per-channel (diff) | |
| signature | ||
Allow bypass of content-type check in utils.http.request
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils/http.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/http.py b/src/utils/http.py index 801e565a..c2ecf35d 100644 --- a/src/utils/http.py +++ b/src/utils/http.py @@ -59,7 +59,7 @@ def request(url: str, method: str="GET", get_params: dict={}, post_data: typing.Any=None, headers: dict={}, json_data: typing.Any=None, code: bool=False, json: bool=False, soup: bool=False, parser: str="lxml", fallback_encoding: str="utf8", - allow_redirects: bool=True + allow_redirects: bool=True, check_content_type: bool=True ) -> Response: if not urllib.parse.urlparse(url).scheme: @@ -96,12 +96,12 @@ def request(url: str, method: str="GET", get_params: dict={}, return response_content.decode(response.encoding or fallback_encoding) if soup: - if content_type in SOUP_CONTENT_TYPES: + if not check_content_type or content_type in SOUP_CONTENT_TYPES: soup = bs4.BeautifulSoup(_decode_data(), parser) return Response(response.status_code, soup, response_headers) else: raise HTTPWrongContentTypeException( - "Tried to soup non-html/non-xml data") + "Tried to soup non-html/non-xml data (%s)" % content_type) data = _decode_data() if json and data: |
