Qt 如何为使用QNetworkRequest发送的请求获取http头的原始字节数据
我正在使用Qt 如何为使用QNetworkRequest发送的请求获取http头的原始字节数据,qt,Qt,我正在使用QNetworkRequest来执行https请求。我想调试它,并在它发送到https服务器之前查看这个类构造的http头的所有内容 到目前为止,我是这样做的: QString header_list; QList<QByteArray> headerList = request->rawHeaderList(); foreach(QByteArray head, headerList) header_list += head + ": " + request-
QNetworkRequest
来执行https请求。我想调试它,并在它发送到https服务器之前查看这个类构造的http头的所有内容
到目前为止,我是这样做的:
QString header_list;
QList<QByteArray> headerList = request->rawHeaderList();
foreach(QByteArray head, headerList)
header_list += head + ": " + request->rawHeader(head) + "\n";
QString头\u列表;
QList headerList=request->rawHeaderList();
foreach(QByteArray头部,头部列表)
header\u list+=head+“:“+请求->rawHeader(head)+”\n”;
这将生成一个字符串,其中包含我使用setRawHeader
显式设置的头的所有部分,但它不会显示默认值或由类本身添加的值,而无需我的干预
通常我会使用tcpdump
查看我的应用程序试图发送到服务器的内容,但它使用的是SSL,所以我不能
我真的很想看到“真正”的标题,它实际上是出去了,这是出于某种原因隐藏在类内部
有没有简单的方法来检索它,以便我可以看到我的应用程序使用的是什么http头?http头是由Qt网络模块设置的。你无法得到它们。
默认标题如下:
Content-Length: 42 // if there is outgoing data
Proxy-Connection: Keep-Alive // if there is http proxy
Connection: Keep-Alive
Accept-Encoding: gzip, deflate
Accept-Language: ru-RU,en,* // depend on system locale
User-Agent: Mozilla/5.0
Host: www.google.com
Content-Type: application/x-www-form-urlencoded // if there is outgoing data, depend on data type