Add QDebug support for QRestReply
Task-number: QTBUG-114705 Change-Id: I6c355d683389b773082c5966434d733bf5aec506 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
6420e8b895
commit
0f34316fb7
@ -367,6 +367,60 @@ QRestReplyPrivate::QRestReplyPrivate()
|
|||||||
QRestReplyPrivate::~QRestReplyPrivate()
|
QRestReplyPrivate::~QRestReplyPrivate()
|
||||||
= default;
|
= default;
|
||||||
|
|
||||||
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
static QLatin1StringView operationName(QNetworkAccessManager::Operation operation)
|
||||||
|
{
|
||||||
|
switch (operation) {
|
||||||
|
case QNetworkAccessManager::Operation::GetOperation:
|
||||||
|
return "GET"_L1;
|
||||||
|
case QNetworkAccessManager::Operation::HeadOperation:
|
||||||
|
return "HEAD"_L1;
|
||||||
|
case QNetworkAccessManager::Operation::PostOperation:
|
||||||
|
return "POST"_L1;
|
||||||
|
case QNetworkAccessManager::Operation::PutOperation:
|
||||||
|
return "PUT"_L1;
|
||||||
|
case QNetworkAccessManager::Operation::DeleteOperation:
|
||||||
|
return "DELETE"_L1;
|
||||||
|
case QNetworkAccessManager::Operation::CustomOperation:
|
||||||
|
return "CUSTOM"_L1;
|
||||||
|
case QNetworkAccessManager::Operation::UnknownOperation:
|
||||||
|
return "UNKNOWN"_L1;
|
||||||
|
}
|
||||||
|
Q_UNREACHABLE_RETURN({});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn QDebug QRestReply::operator<<(QDebug debug, const QRestReply *reply)
|
||||||
|
|
||||||
|
Writes the \a reply into the \a debug object for debugging purposes.
|
||||||
|
|
||||||
|
\sa {Debugging Techniques}
|
||||||
|
*/
|
||||||
|
QDebug operator<<(QDebug debug, const QRestReply *reply)
|
||||||
|
{
|
||||||
|
const QDebugStateSaver saver(debug);
|
||||||
|
debug.resetFormat().nospace();
|
||||||
|
if (!reply) {
|
||||||
|
debug << "QRestReply(nullptr)";
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
debug << "QRestReply(isSuccess = " << reply->isSuccess()
|
||||||
|
<< ", httpStatus = " << reply->httpStatus()
|
||||||
|
<< ", isHttpStatusSuccess = " << reply->isHttpStatusSuccess()
|
||||||
|
<< ", hasError = " << reply->hasError()
|
||||||
|
<< ", errorString = " << reply->errorString()
|
||||||
|
<< ", error = " << reply->error()
|
||||||
|
<< ", isFinished = " << reply->isFinished()
|
||||||
|
<< ", bytesAvailable = " << reply->bytesAvailable()
|
||||||
|
<< ", url " << reply->networkReply()->url()
|
||||||
|
<< ", operation = " << operationName(reply->networkReply()->operation())
|
||||||
|
<< ", reply headers = " << reply->networkReply()->rawHeaderPairs()
|
||||||
|
<< ")";
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
#endif // QT_NO_DEBUG_STREAM
|
||||||
|
|
||||||
QByteArray QRestReplyPrivate::contentCharset() const
|
QByteArray QRestReplyPrivate::contentCharset() const
|
||||||
{
|
{
|
||||||
// Content-type consists of mimetype and optional parameters, of which one may be 'charset'
|
// Content-type consists of mimetype and optional parameters, of which one may be 'charset'
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QDebug;
|
||||||
class QRestReplyPrivate;
|
class QRestReplyPrivate;
|
||||||
class Q_NETWORK_EXPORT QRestReply : public QObject
|
class Q_NETWORK_EXPORT QRestReply : public QObject
|
||||||
{
|
{
|
||||||
@ -49,6 +50,9 @@ Q_SIGNALS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QRestAccessManagerPrivate;
|
friend class QRestAccessManagerPrivate;
|
||||||
|
#ifndef QT_NO_DEBUG_STREAM
|
||||||
|
friend Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QRestReply *reply);
|
||||||
|
#endif
|
||||||
explicit QRestReply(QNetworkReply *reply, QObject *parent = nullptr);
|
explicit QRestReply(QNetworkReply *reply, QObject *parent = nullptr);
|
||||||
Q_DECLARE_PRIVATE(QRestReply)
|
Q_DECLARE_PRIVATE(QRestReply)
|
||||||
Q_DISABLE_COPY_MOVE(QRestReply)
|
Q_DISABLE_COPY_MOVE(QRestReply)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user