38 QByteArray.number(fileData.length())) |
38 QByteArray.number(fileData.length())) |
39 self.setAttribute(QNetworkRequest.HttpStatusCodeAttribute, 200) |
39 self.setAttribute(QNetworkRequest.HttpStatusCodeAttribute, 200) |
40 self.setAttribute(QNetworkRequest.HttpReasonPhraseAttribute, "OK") |
40 self.setAttribute(QNetworkRequest.HttpReasonPhraseAttribute, "OK") |
41 QTimer.singleShot(0, lambda: self.metaDataChanged.emit()) |
41 QTimer.singleShot(0, lambda: self.metaDataChanged.emit()) |
42 QTimer.singleShot(0, lambda: self.readyRead.emit()) |
42 QTimer.singleShot(0, lambda: self.readyRead.emit()) |
|
43 QTimer.singleShot(0, lambda: self.finished.emit()) |
43 |
44 |
44 def abort(self): |
45 def abort(self): |
45 """ |
46 """ |
46 Public slot to abort the operation. |
47 Public slot to abort the operation. |
47 """ |
48 """ |
52 """ |
53 """ |
53 Public method to determined the bytes available for being read. |
54 Public method to determined the bytes available for being read. |
54 |
55 |
55 @return bytes available (integer) |
56 @return bytes available (integer) |
56 """ |
57 """ |
57 if self.__data.length() == 0: |
|
58 QTimer.singleShot(0, lambda: self.finished.emit()) |
|
59 return self.__data.length() + QNetworkReply.bytesAvailable(self) |
58 return self.__data.length() + QNetworkReply.bytesAvailable(self) |
60 |
59 |
61 def readData(self, maxlen): |
60 def readData(self, maxlen): |
62 """ |
61 """ |
63 Protected method to retrieve data from the reply object. |
62 Protected method to retrieve data from the reply object. |
66 @return string containing the data (bytes) |
65 @return string containing the data (bytes) |
67 """ |
66 """ |
68 len_ = min(maxlen, self.__data.length()) |
67 len_ = min(maxlen, self.__data.length()) |
69 buffer = bytes(self.__data[:len_]) |
68 buffer = bytes(self.__data[:len_]) |
70 self.__data.remove(0, len_) |
69 self.__data.remove(0, len_) |
71 if self.__data.length() == 0: |
|
72 QTimer.singleShot(0, lambda: self.finished.emit()) |
|
73 return buffer |
70 return buffer |
|
71 |
|
72 def isFinished(self): |
|
73 """ |
|
74 Public method to check, if the reply has finished. |
|
75 |
|
76 @return flag indicating the finished state (boolean) |
|
77 """ |
|
78 return True |