From 02b818af04de69e3ccd761fa7c8a037fde7da9d6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 17 Apr 2018 15:04:36 +0200 Subject: Download: Use the from the reply in the error message if any Issue: #6459 --- test/syncenginetestutils.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'test/syncenginetestutils.h') diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h index 06c35d300..f07f93fda 100644 --- a/test/syncenginetestutils.h +++ b/test/syncenginetestutils.h @@ -715,8 +715,8 @@ class FakeErrorReply : public QNetworkReply Q_OBJECT public: FakeErrorReply(QNetworkAccessManager::Operation op, const QNetworkRequest &request, - QObject *parent, int httpErrorCode) - : QNetworkReply{parent}, _httpErrorCode(httpErrorCode) { + QObject *parent, int httpErrorCode, const QByteArray &body = QByteArray()) + : QNetworkReply{parent}, _httpErrorCode(httpErrorCode), _body(body) { setRequest(request); setUrl(request.url()); setOperation(op); @@ -732,9 +732,15 @@ public: } void abort() override { } - qint64 readData(char *, qint64) override { return 0; } + qint64 readData(char *buf, qint64 max) override { + max = qMin(max, _body.size()); + memcpy(buf, _body.constData(), max); + _body = _body.mid(max); + return max; + } int _httpErrorCode; + QByteArray _body; }; // A reply that never responds -- cgit v1.2.3