For Debugging purposes, I would like to examine the QNetworkRequest
s that I build and see if they are formatted correctly.
However, I do not see how to output them to a string format based upon their api.
How can I go about viewing the raw http request?
You can use something like this to debug your requests generally:
#include <QDebug>
void debugRequest(QNetworkRequest request, QByteArray data = QByteArray())
{
qDebug() << request.url().toString(); //output the url
const QList<QByteArray>& rawHeaderList(request.rawHeaderList());
foreach (QByteArray rawHeader, rawHeaderList) { //traverse and output the header
qDebug() << request.rawHeader(rawHeader);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.