如何在QNetworkRequest中设置“连接:关闭”

时间:2018-07-17 08:41:39

标签: qt http networking

我添加

m_request.setRawHeader("Connection", "close");

但是使用Wireshark进行检查时,我发现标头包含一个"Keep-Alive"

我调试了Qt,发现“ network / access / qhttpnetworkconnection.cpp ” 设置Keep-Alive忽略我的标题。

void QHttpNetworkConnectionPrivate::prepareRequest(HttpMessagePair &messagePair)" 
...
if (networkProxy.type() == QNetworkProxy::HttpCachingProxy)  {
    value = request.headerField("proxy-connection");
    if (value.isEmpty())
        request.setHeaderField("Proxy-Connection", "Keep-Alive");
} else {
#endif
    value = request.headerField("connection");
    if (value.isEmpty())
        request.setHeaderField("Connection", "Keep-Alive");
#ifndef QT_NO_NETWORKPROXY
}

有人知道如何设置“连接:关闭”吗?

-

编辑:似乎不可能

QNetworkRequest:能够取消设置一些可选的标头条目 https://bugreports.qt.io/browse/QTBUG-9463

8岁的错误仍未解决...

0 个答案:

没有答案