Reputation: 2478
HTTP 1.1 supports persistent connection by default, so I want to send my a second http request using the same connection that was setup when the first HTTP request was made. how can this be achieved through Qt?
If I simply make the second request after the first one finished like the following
manager->get(QNetworkRequest(QUrl("http://qt-project.org")));
it seems a new TCP connection to the server will be initiated (I have checked with a network sniffer) The experiment also says: If the reply is deleteLater() or abort() within finished() signal, the connection will be closed.
Upvotes: 4
Views: 4160
Reputation: 401
You can do the following to investigate further:
Connection: Keep-Alive
header set.Connection: Close
set by the webserverSometimes webservers don't honor the keep-alive
header and will send a close
anyway. In this case the client is rightfully closing the connection.
Upvotes: 1