Adds 304 http status code as valid.

Signed-off-by: Camila San <hello@camila.codes>
This commit is contained in:
Camila San 2018-04-10 15:40:17 +02:00
parent 77ebccee72
commit 23a759ef4a
No known key found for this signature in database
GPG Key ID: 7A4A6121E88E2AD4

View File

@ -106,18 +106,24 @@ bool OcsJob::finished()
const QByteArray replyData = reply()->readAll();
QJsonParseError error;
QString message;
int statusCode = 0;
auto json = QJsonDocument::fromJson(replyData, &error);
// when it is null we might have a 304 so get status code from reply() and gives a warning...
if (error.error != QJsonParseError::NoError) {
statusCode = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
qCWarning(lcOcs) << "Could not parse reply to"
<< _verb
<< Utility::concatUrlPath(account()->url(), path())
<< _params
<< error.errorString()
<< ":" << replyData;
} else {
statusCode = getJsonReturnCode(json, message);
}
QString message;
const int statusCode = getJsonReturnCode(json, message);
//... then it checks for the statusCode
if (!_passStatusCodes.contains(statusCode)) {
qCWarning(lcOcs) << "Reply to"
<< _verb
@ -125,6 +131,7 @@ bool OcsJob::finished()
<< _params
<< "has unexpected status code:" << statusCode << replyData;
emit ocsError(statusCode, message);
} else {
// save new ETag value
if(reply()->rawHeaderList().contains("ETag"))