diff options
author | Philipp Hörist <philipp@hoerist.com> | 2023-01-02 00:12:01 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2023-01-02 00:12:01 +0300 |
commit | 1dbc2ed48b979cb95bcb8b0f0d43cd03fd55fcfd (patch) | |
tree | 1ec08b78470ebe716277781f90d60bb64325ab17 | |
parent | 156a365a688f7e5071c2d1a6fa36d3d5227dc4f4 (diff) |
cfix: HTTP: Handle case where sniffer omits content-type
-rw-r--r-- | nbxmpp/http.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/nbxmpp/http.py b/nbxmpp/http.py index 8f50b04..6d37acd 100644 --- a/nbxmpp/http.py +++ b/nbxmpp/http.py @@ -403,7 +403,7 @@ class HTTPRequest(GObject.GObject): def _on_content_sniffed(self, message: Soup.Message, - content_type: str, + content_type: Optional[str], _params: GLib.HashTable, ) -> None: @@ -419,7 +419,12 @@ class HTTPRequest(GObject.GObject): self.cancel() return - self._response_content_type = content_type + if content_type is None: + # According to the docs, content_type is None when the sniffer + # decides to trust the content-type sent by the server. + self._response_content_type = headers.get_content_type() + else: + self._response_content_type = content_type self._log.info('Sniffed: content-type: %s, content-length: %s', self._response_content_type, |