summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2024-03-05 14:36:09 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2024-03-12 14:23:56 +0100
commitbe6644c1f254cce796c43d7c1eae3ae794bb77be (patch)
tree095e72a8d049c1912411060732c37acc3e7efa6a /src/network
parent22c99cf498103c86baa5a415ca34630396e5b6aa (diff)
Http: fix issues after early abort()
There were a few issues to deal with. One of them was that we would print a warning about an internal error if we tried to *set* an error on the reply after it had been cancelled. That's kind of unavoidable since these things happen in different threads, so just ignore the error if we have been cancelled. The other issue was that, for a request with data, we will buffer the data to send, and _only then_ do we start the request. This happens asynchronously, so the user can abort the request before it has finished buffering. Once it finished buffering it would set the state of the request to "Working", ignoring that it was already marked "Finished". Fixes: QTBUG-118209 Fixes: QTBUG-36127 Pick-to: 6.7 6.6 Change-Id: Idbf1fd8a80530d802bee04c4b0a6783cba4992d3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qnetworkreplyhttpimpl.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/network/access/qnetworkreplyhttpimpl.cpp b/src/network/access/qnetworkreplyhttpimpl.cpp
index acb9164372..1eee98f834 100644
--- a/src/network/access/qnetworkreplyhttpimpl.cpp
+++ b/src/network/access/qnetworkreplyhttpimpl.cpp
@@ -1889,7 +1889,9 @@ void QNetworkReplyHttpImplPrivate::setResumeOffset(quint64 offset)
void QNetworkReplyHttpImplPrivate::_q_startOperation()
{
- if (state == Working) // ensure this function is only being called once
+ // Ensure this function is only being called once, and not at all if we were
+ // cancelled
+ if (state >= Working)
return;
state = Working;
@@ -2157,7 +2159,9 @@ void QNetworkReplyHttpImplPrivate::error(QNetworkReplyImpl::NetworkError code, c
Q_Q(QNetworkReplyHttpImpl);
// Can't set and emit multiple errors.
if (errorCode != QNetworkReply::NoError) {
- qWarning("QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once.");
+ // But somewhat unavoidable if we have cancelled the request:
+ if (errorCode != QNetworkReply::OperationCanceledError)
+ qWarning("QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once.");
return;
}