summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@gmail.com>2020-09-17 11:21:09 +1000
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-09-25 03:48:57 +0000
commit61be29d3650426dc54d46fdc9638ce66ecf588f4 (patch)
treed7267cddb26c6581a3429bb6a550de7e1f3be820 /src
parente041f5459660eaa7108fa5888e77e64f7d1b3d1d (diff)
downloadqtbase-61be29d3650426dc54d46fdc9638ce66ecf588f4.tar.gz
wasm: fix network status code propagation
Fixes: QTBUG-86620 Change-Id: I911636739dc57e47bc2a07a583f4e67fc08b1b19 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> (cherry picked from commit 49517aad70675433df6519b2071d11e5ebaa209a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/network/access/qnetworkreplywasmimpl.cpp19
-rw-r--r--src/network/access/qnetworkreplywasmimpl_p.h1
2 files changed, 14 insertions, 6 deletions
diff --git a/src/network/access/qnetworkreplywasmimpl.cpp b/src/network/access/qnetworkreplywasmimpl.cpp
index 1809672401..0fc5bbf5a8 100644
--- a/src/network/access/qnetworkreplywasmimpl.cpp
+++ b/src/network/access/qnetworkreplywasmimpl.cpp
@@ -283,6 +283,7 @@ void QNetworkReplyWasmImplPrivate::emitReplyError(QNetworkReply::NetworkError er
q->setError(errorCode, errorString);
emit q->errorOccurred(errorCode);
+ emit q->finished();
}
void QNetworkReplyWasmImplPrivate::emitDataReadProgress(qint64 bytesReceived, qint64 bytesTotal)
@@ -315,12 +316,6 @@ void QNetworkReplyWasmImplPrivate::dataReceived(const QByteArray &buffer, int bu
downloadBuffer.append(buffer, bufferSize);
emit q->readyRead();
-
- if (downloadBufferCurrentSize == totalDownloadSize) {
- q->setFinished(true);
- emit q->readChannelFinished();
- emit q->finished();
- }
}
//taken from qnetworkrequest.cpp
@@ -457,6 +452,10 @@ void QNetworkReplyWasmImplPrivate::downloadSucceeded(emscripten_fetch_t *fetch)
if (reply) {
QByteArray buffer(fetch->data, fetch->numBytes);
reply->dataReceived(buffer, buffer.size());
+
+ QByteArray statusText(fetch->statusText);
+ reply->setStatusCode(fetch->status, statusText);
+ reply->setReplyFinished();
}
}
@@ -467,6 +466,14 @@ void QNetworkReplyWasmImplPrivate::setStatusCode(int status, const QByteArray &s
q->setAttribute(QNetworkRequest::HttpReasonPhraseAttribute, statusText);
}
+void QNetworkReplyWasmImplPrivate::setReplyFinished()
+{
+ Q_Q(QNetworkReplyWasmImpl);
+ q->setFinished(true);
+ emit q->readChannelFinished();
+ emit q->finished();
+}
+
void QNetworkReplyWasmImplPrivate::stateChange(emscripten_fetch_t *fetch)
{
if (fetch->readyState == /*HEADERS_RECEIVED*/ 2) {
diff --git a/src/network/access/qnetworkreplywasmimpl_p.h b/src/network/access/qnetworkreplywasmimpl_p.h
index f8e532ff98..53e9bc3375 100644
--- a/src/network/access/qnetworkreplywasmimpl_p.h
+++ b/src/network/access/qnetworkreplywasmimpl_p.h
@@ -147,6 +147,7 @@ public:
static QNetworkReply::NetworkError statusCodeFromHttp(int httpStatusCode, const QUrl &url);
emscripten_fetch_t *m_fetch;
+ void setReplyFinished();
Q_DECLARE_PUBLIC(QNetworkReplyWasmImpl)
};