summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMarkus Goetz <Markus.Goetz@nokia.com>2011-04-13 14:33:11 +0200
committerMarkus Goetz <Markus.Goetz@nokia.com>2011-05-03 16:47:07 +0200
commit9aa2feec0e579c7e1bfcf990aae07a82daaad647 (patch)
treefd30e30b016626038ef06f95ad70474ef92ebf45 /src/network
parent718657d8b24ebd8f9004f41e79e6bd79c385b316 (diff)
QNAM HTTP: Implement abort() and close()
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index 7e6f2d4b5e..359fb563e5 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -250,15 +250,40 @@ QNetworkReplyHttpImpl::~QNetworkReplyHttpImpl()
void QNetworkReplyHttpImpl::close()
{
Q_D(QNetworkReplyHttpImpl);
+
+ if (d->state == QNetworkReplyHttpImplPrivate::Aborted ||
+ d->state == QNetworkReplyHttpImplPrivate::Finished)
+ return;
+
+ // According to the documentation close only stops the download
+ // by closing we can ignore the download part and continue uploading.
QNetworkReply::close();
- // FIXME
+
+ // call finished which will emit signals
+ // FIXME shouldn't this be emitted Queued?
+ d->error(OperationCanceledError, tr("Operation canceled"));
+ d->finished();
}
void QNetworkReplyHttpImpl::abort()
{
Q_D(QNetworkReplyHttpImpl);
- QNetworkReply::close();
// FIXME
+ if (d->state == QNetworkReplyHttpImplPrivate::Finished || d->state == QNetworkReplyHttpImplPrivate::Aborted)
+ return;
+
+ QNetworkReply::close();
+
+ if (d->state != QNetworkReplyHttpImplPrivate::Finished) {
+ // call finished which will emit signals
+ // FIXME shouldn't this be emitted Queued?
+ d->error(OperationCanceledError, tr("Operation canceled"));
+ d->finished();
+ }
+
+ d->state = QNetworkReplyHttpImplPrivate::Aborted;
+
+ emit abortHttpRequest();
}
qint64 QNetworkReplyHttpImpl::bytesAvailable() const
@@ -935,6 +960,10 @@ void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d)
qDebug() << "QNetworkReplyHttpImplPrivate::replyDownloadData" << d.size();
+ // If we're closed just ignore this data
+ if (!q->isOpen())
+ return;
+
int pendingSignals = (int)pendingDownloadDataEmissions->fetchAndAddAcquire(-1) - 1;
if (pendingSignals > 0) {
@@ -959,10 +988,6 @@ void QNetworkReplyHttpImplPrivate::replyDownloadData(QByteArray d)
//writeDownstreamData(pendingDownloadDataCopy);
// instead we do:
- // We could be closed
- if (!q->isOpen())
- return;
-
if (cacheEnabled && !cacheSaveDevice) {
initCacheSaveDevice();
}
@@ -1126,6 +1151,10 @@ void QNetworkReplyHttpImplPrivate::replyDownloadProgressSlot(qint64 bytesReceive
{
Q_Q(QNetworkReplyHttpImpl);
+ // If we're closed just ignore this data
+ if (!q->isOpen())
+ return;
+
// we can be sure here that there is a download buffer
int pendingSignals = (int)pendingDownloadProgressEmissions->fetchAndAddAcquire(-1) - 1;