mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 06:19:02 +02:00
Clean up HTTPResourceRequest
This commit is contained in:
parent
3eff605d72
commit
12b2dfb2f9
1 changed files with 6 additions and 7 deletions
|
@ -54,12 +54,10 @@ void HTTPResourceRequest::onRequestFinished() {
|
||||||
Q_ASSERT(_reply);
|
Q_ASSERT(_reply);
|
||||||
|
|
||||||
_state = FINISHED;
|
_state = FINISHED;
|
||||||
|
|
||||||
auto error = _reply->error();
|
auto error = _reply->error();
|
||||||
qDebug() << "Loaded " << _url;
|
|
||||||
QString u = _url.path();
|
|
||||||
if (error == QNetworkReply::NoError) {
|
if (error == QNetworkReply::NoError) {
|
||||||
_data = _reply->readAll();
|
_data = _reply->readAll();
|
||||||
qDebug() << "!!!! " << _data.size() << " " << _url.path();
|
|
||||||
_loadedFromCache = _reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool();
|
_loadedFromCache = _reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool();
|
||||||
_result = ResourceRequest::SUCCESS;
|
_result = ResourceRequest::SUCCESS;
|
||||||
emit finished();
|
emit finished();
|
||||||
|
@ -70,27 +68,28 @@ void HTTPResourceRequest::onRequestFinished() {
|
||||||
_result = ResourceRequest::ERROR;
|
_result = ResourceRequest::ERROR;
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
_reply->deleteLater();
|
_reply->deleteLater();
|
||||||
_reply = nullptr;
|
_reply = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
|
void HTTPResourceRequest::onDownloadProgress(qint64 bytesReceived, qint64 bytesTotal) {
|
||||||
if (_state == IN_PROGRESS) {
|
if (_state == IN_PROGRESS) {
|
||||||
// Restart timer
|
// We've received data, so reset the timer
|
||||||
_sendTimer.start();
|
_sendTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit progress(bytesReceived, bytesTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTTPResourceRequest::onTimeout() {
|
void HTTPResourceRequest::onTimeout() {
|
||||||
Q_ASSERT(_state != UNSENT);
|
Q_ASSERT(_state != UNSENT);
|
||||||
|
|
||||||
// TODO Cancel request if timed out, handle properly in
|
|
||||||
// receive callback
|
|
||||||
if (_state == IN_PROGRESS) {
|
if (_state == IN_PROGRESS) {
|
||||||
qCDebug(networking) << "Timed out loading " << _url;
|
qCDebug(networking) << "Timed out loading " << _url;
|
||||||
|
_reply->abort();
|
||||||
_state = FINISHED;
|
_state = FINISHED;
|
||||||
_result = TIMEOUT;
|
_result = TIMEOUT;
|
||||||
_reply->abort();
|
|
||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue