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