Philipp Hörist pushed to branch master at gajim / python-nbxmpp
Commits:
feffa352 by Philipp Hörist at 2023-01-01T20:47:12+01:00
new: HTTP: Add more logging
- - - - -
8fc874b6 by Philipp Hörist at 2023-01-01T20:48:19+01:00
cfix: Don’t sniff content on unsuccessful responses
- - - - -
156a365a by Philipp Hörist at 2023-01-01T22:00:31+01:00
cfix: HTTP: Don’t special handle contet-length of zero
- - - - -
1 changed file:
- nbxmpp/http.py
Changes:
=====================================
nbxmpp/http.py
=====================================
@@ -290,7 +290,7 @@ class HTTPRequest(GObject.GObject):
self._timeout_id = GLib.timeout_add_seconds(
timeout, self._on_timeout)
- self._log.info('Request sent')
+ self._log.info('Request sent, method: %s, uri: %s', method, uri_string)
def _on_request_body_progress(self,
_message: Soup.Message,
@@ -325,8 +325,10 @@ class HTTPRequest(GObject.GObject):
self._set_failed(HTTPRequestError.UNKNOWN)
return
- if self._message.get_status() not in (Soup.Status.OK,
- Soup.Status.CREATED):
+ status = self._message.get_status()
+ if status not in (Soup.Status.OK, Soup.Status.CREATED):
+ self._log.info('Response status: %s %s',
+ int(status), self._message.get_reason_phrase())
self._set_failed(HTTPRequestError.STATUS_NOT_OK)
return
@@ -405,6 +407,10 @@ class HTTPRequest(GObject.GObject):
_params: GLib.HashTable,
) -> None:
+ if self._message.get_status() not in (Soup.Status.OK,
+ Soup.Status.CREATED):
+ return
+
headers = message.get_response_headers()
encoding = headers.get_encoding()
if Soup.Encoding.CONTENT_LENGTH not in convert_soup_encoding(encoding):
@@ -413,14 +419,12 @@ class HTTPRequest(GObject.GObject):
self.cancel()
return
- self._response_content_length = headers.get_content_length()
- if self._response_content_length == 0:
- self._log.warning('No content-length in response')
- self._no_content_length_set = True
- self.cancel()
- return
-
self._response_content_type = content_type
+
+ self._log.info('Sniffed: content-type: %s, content-length: %s',
+ self._response_content_type,
+ self._response_content_length)
+
self.emit('content-sniffed',
self._response_content_length,
self._response_content_type)
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/compare/4bed9a95bf654147b9cb74a88e9f84ec5cdd77e3...156a365a688f7e5071c2d1a6fa36d3d5227dc4f4
--
View it on GitLab:
https://dev.gajim.org/gajim/python-nbxmpp/-/compare/4bed9a95bf654147b9cb74a88e9f84ec5cdd77e3...156a365a688f7e5071c2d1a6fa36d3d5227dc4f4
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits