[Interest] Does QNetworkAccessManager support HTTP persistent connections? (keep-alive)

Sze Howe Koh szehowe.koh at gmail.com
Thu Jul 26 02:59:07 CEST 2018


On Thu, 26 Jul 2018 at 08:57, Sze Howe Koh <szehowe.koh at gmail.com> wrote:
>
> On Thu, 26 Jul 2018 at 05:44, Thiago Macieira <thiago.macieira at intel.com> wrote:
> >
> > On Wednesday, 25 July 2018 10:22:19 PDT Thiago Macieira wrote:
> > > On Wednesday, 25 July 2018 07:52:13 PDT Marian Beermann wrote:
> > > > Correct. If you augment your debugging a little, it is easy to see the
> > > > server sending a "Connection: close" header:
> > > >
> > > > qDebug() << ... << reply->rawHeader("Connection");
> > >
> > > The question is whether the request had a "Connection: keep-alive" header.
> > > You need to check the Wireshark logs to see that.
> >
> > Or if the request was HTTP/1.1, which changed the Connection default to keep-
> > alive.
>
> The reply's "Connection" header was "close", and Wireshark's traces
> have no mention keep-alive.
>
> Explicitly setting the "Connection" header in the request had no effect:
>
>     for (auto url : urls)
>     {
>         QNetworkRequest req(url);
>         req.setRawHeader("Connection", "keep-alive");
>         auto reply = nam.get(req);
>         QObject::connect(reply, &QNetworkReply::finished, [=]
>         {
>             qDebug() << reply->request().url();
>             qDebug() << '\t' << "Reqst:" <<
> reply->request().rawHeader("Connection");
>             qDebug() << '\t' << "Reply:" << reply->rawHeader("Connection");
>             reply->deleteLater();
>         });
>     }
>
> Debug outputs:
>
>     QUrl("http://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_59/qt.59.win64_msvc2015_64/5.9.0-0-201705291821meta.7z")
>         Reqst: "keep-alive"
>         Reply: "close"
>>
> Does this mean the server is ignoring the keep-alive flag? How do I
> check if QNAM is setting it correctly in the first place?

I think the comms was HTTP 1.1, because Wireshark showed "HTTP/1.1 200
OK    (text/plain)"


Regards,
Sze Howe



More information about the Interest mailing list