From: Olivier Goffart Date: Tue, 17 Apr 2018 13:04:36 +0000 (+0200) Subject: Download: Use the from the reply in the error message if any X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~603 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=718843ffce4f76131262f728ae214fa252213bc2;p=nextcloud-desktop.git Download: Use the from the reply in the error message if any Issue: #6459 --- diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 6134f1e2a..9504ea6f0 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -657,7 +657,7 @@ void PropagateDownloadFile::slotGetFinished() &propagator()->_anotherSyncNeeded); } - done(status, job->errorString()); + done(status,_item->_httpErrorCode >= 400 ? job->errorStringParsingBody() : job->errorString()); return; } diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h index 40dab4487..3b4a40f5e 100644 --- a/test/syncenginetestutils.h +++ b/test/syncenginetestutils.h @@ -717,8 +717,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); @@ -747,9 +747,15 @@ public slots: 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