[Backport release-10.x] Network: log server response on error (#4732)

This commit is contained in:
Alexandru Ionut Tripon 2026-01-11 15:20:24 +02:00 committed by GitHub
commit 702d4eb75c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -169,9 +169,11 @@ void NetRequest::downloadError(QNetworkReply::NetworkError error)
}
}
// error happened during download.
qCCritical(logCat) << getUid().toString() << "Failed" << m_url.toString() << "with reason" << error;
qCCritical(logCat) << getUid().toString() << "Failed" << m_url.toString() << "with error" << error;
if (m_reply)
qCCritical(logCat) << getUid().toString() << "HTTP Status" << replyStatusCode() << ";error" << errorString();
qCCritical(logCat) << getUid().toString() << "HTTP status:" << replyStatusCode() << errorString();
if (m_errorResponse.size() > 0)
qCCritical(logCat) << getUid().toString() << "Response from server:" << m_errorResponse;
m_state = State::Failed;
}
}
@ -308,6 +310,9 @@ void NetRequest::downloadReadyRead()
if (m_state == State::Running) {
auto data = m_reply->readAll();
m_state = m_sink->write(data);
if (replyStatusCode() >= 400) {
m_errorResponse.append(data);
}
if (m_state == State::Failed) {
qCCritical(logCat) << getUid().toString() << "Failed to process response chunk:" << m_sink->failReason();
}

View file

@ -104,6 +104,7 @@ class NetRequest : public Task {
/// the network reply
unique_qobject_ptr<QNetworkReply> m_reply;
QByteArray m_errorResponse;
/// source URL
QUrl m_url;