diff options
| author | Juha Vuolle <juha.vuolle@qt.io> | 2024-01-26 12:53:34 +0200 |
|---|---|---|
| committer | Marc Mutz <marc.mutz@qt.io> | 2024-01-30 03:39:40 +0000 |
| commit | bd78ff024599d33cfcb411ff17727a0f4447bc7e (patch) | |
| tree | 7df198b0be20e9e9bf366c7ef3730024041c4392 /src/network/access/qrestreply.cpp | |
| parent | 264d54953e8b53f2454fbf8361b851923b8115a5 (diff) | |
Rename QRestReply data accessors as read* functions
This naming should make it clearer that (successful) calls to
readJson(), readBody(), and readText() consume the data received
so far.
Resulted from API-review
Pick-to: 6.7
Change-Id: I09ca9eac598f8fc83eecb72c22431ac35b966bf5
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/network/access/qrestreply.cpp')
| -rw-r--r-- | src/network/access/qrestreply.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/network/access/qrestreply.cpp b/src/network/access/qrestreply.cpp index 7cf9975ecc4..07ffe06c6f3 100644 --- a/src/network/access/qrestreply.cpp +++ b/src/network/access/qrestreply.cpp @@ -102,9 +102,9 @@ QNetworkReply *QRestReply::networkReply() const set to QJsonParseError::NoError to distinguish this case from an actual error. - \sa body(), text() + \sa readBody(), readText() */ -std::optional<QJsonDocument> QRestReply::json(QJsonParseError *error) +std::optional<QJsonDocument> QRestReply::readJson(QJsonParseError *error) { if (!wrapped) { if (error) @@ -113,7 +113,7 @@ std::optional<QJsonDocument> QRestReply::json(QJsonParseError *error) } if (!wrapped->isFinished()) { - qCWarning(lcQrest, "Attempt to read json() of an unfinished reply, ignoring."); + qCWarning(lcQrest, "readJson() called on an unfinished reply, ignoring"); if (error) *error = {0, QJsonParseError::ParseError::NoError}; return std::nullopt; @@ -135,10 +135,10 @@ std::optional<QJsonDocument> QRestReply::json(QJsonParseError *error) calls to get response data will return empty until further data has been received. - \sa json(), text(), QNetworkReply::bytesAvailable(), + \sa readJson(), readText(), QNetworkReply::bytesAvailable(), QNetworkReply::readyRead() */ -QByteArray QRestReply::body() +QByteArray QRestReply::readBody() { return wrapped ? wrapped->readAll() : QByteArray{}; } @@ -157,9 +157,9 @@ QByteArray QRestReply::body() decoding is not supported by \l QStringConverter, or if the decoding has errors (for example invalid characters). - \sa json(), body(), QNetworkReply::readyRead() + \sa readJson(), readBody(), QNetworkReply::readyRead() */ -QString QRestReply::text() +QString QRestReply::readText() { QString result; if (!wrapped) @@ -178,13 +178,13 @@ QString QRestReply::text() const QByteArray charset = QRestReplyPrivate::contentCharset(wrapped); d->decoder = QStringDecoder(charset); if (!d->decoder->isValid()) { // the decoder may not support the mimetype's charset - qCWarning(lcQrest, "text(): Charset \"%s\" is not supported", charset.constData()); + qCWarning(lcQrest, "readText(): Charset \"%s\" is not supported", charset.constData()); return result; } } // Check if the decoder already had an error, or has errors after decoding current data chunk if (d->decoder->hasError() || (result = (*d->decoder)(data), d->decoder->hasError())) { - qCWarning(lcQrest, "text() Decoding error occurred"); + qCWarning(lcQrest, "readText(): Decoding error occurred"); return {}; } return result; |
