def __init__(self, parent, request, mime_type, name): QNetworkReply.__init__(self, parent) self.setOpenMode(QNetworkReply.ReadOnly | QNetworkReply.Unbuffered) self.setRequest(request) self.setUrl(request.url()) self._aborted = False if mime_type in OEB_DOCS: self.resource_name = name QTimer.singleShot(0, self.check_for_parse) else: data = get_data(name) if isinstance(data, type('')): data = data.encode('utf-8') mime_type += '; charset=utf-8' self.__data = data self.setHeader(QNetworkRequest.ContentTypeHeader, mime_type) self.setHeader(QNetworkRequest.ContentLengthHeader, len(self.__data)) QTimer.singleShot(0, self.finalize_reply) if mime_type in OEB_FONTS: font_cache.add_font(data) # We prevent the use of the embedded font because of the the # bug in Qt WebKit, # https://bugs.webkit.org/show_bug.cgi?id=29433 self.__data = b''
def __init__(self, parent, request, mime_type, name): QNetworkReply.__init__(self, parent) self.setOpenMode(QNetworkReply.ReadOnly | QNetworkReply.Unbuffered) self.setRequest(request) self.setUrl(request.url()) self._aborted = False if mime_type in OEB_DOCS: self.resource_name = name QTimer.singleShot(0, self.check_for_parse) else: data = get_data(name) if isinstance(data, type('')): data = data.encode('utf-8') mime_type += '; charset=utf-8' self.__data = data self.setHeader(QNetworkRequest.ContentTypeHeader, mime_type) self.setHeader(QNetworkRequest.ContentLengthHeader, len(self.__data)) QTimer.singleShot(0, self.finalize_reply)