PDA

View Full Version : Cannot set "Connection: close" in QNetworkRequest



trallallero
17th July 2018, 10:51
I add


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

but checking with Wireshark, I see that the header contains a "Keep-Alive".

I debugged Qt and seen that "network/access/qhttpnetworkconnection.cpp"
sets the Keep-Alive ignoring my header.


void QHttpNetworkConnectionPrivate::prepareRequest(Http MessagePair &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
}

Does someone know how to set a "Connection: close"?

Added after 25 minutes:

It seems not possible:
https://bugreports.qt.io/browse/QTBUG-9463