Add logging to custom requests.

This commit is contained in:
Florian Bruhin 2014-02-21 07:35:53 +01:00
parent daa3808b7f
commit 29c84f4f20
2 changed files with 7 additions and 0 deletions

View File

@ -17,6 +17,8 @@
"""Handler functions for different qute:... pages."""
import logging
from qutebrowser.network.schemehandler import (SchemeHandler,
SpecialNetworkReply)
from qutebrowser.utils.version import version
@ -104,6 +106,7 @@ class QuteSchemeHandler(SchemeHandler):
# FIXME handle unknown pages
# FIXME adjust URLutils based on handlers
logging.debug('request: {}'.format(request))
data = handle(urlstring(request.url()))
return SpecialNetworkReply(request, data, "text/html", self.parent())

View File

@ -20,6 +20,8 @@
"""Base class for custom scheme handlers."""
import logging
from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
from PyQt5.QtCore import pyqtSlot, QObject, QIODevice, QByteArray
@ -96,6 +98,7 @@ class SpecialNetworkReply(QNetworkReply):
if self._data.length() == 0:
self.finished.emit()
return self._data.length() + super().bytesAvailable()
logging.debug("bytes available: {}".format(len(self._data)))
def readData(self, maxlen):
"""Retrieve data from the reply object.
@ -115,4 +118,5 @@ class SpecialNetworkReply(QNetworkReply):
self._data.remove(0, len_)
if self._data.length() == 0:
self.finished.emit()
logging.debug("readdata, len {}, maxlen {}, buf {}".format(len(self._data), maxlen, buf))
return buf