[Interest] QNetworkAccessManager and HTTP persistent connection
Mandeep Sandhu
mandeepsandhu.chd at gmail.com
Tue Nov 26 06:44:22 CET 2013
On Sat, Nov 23, 2013 at 7:15 PM, iMath <2281570025 at qq.com> wrote:
> 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?
I think you meant HTTP "pipelining" (that's the jargon used inside Qt
code). I'm not 100% sure but in Qt5, the default _should_ be to use
HTTP pipelining.
In any case, you can explcitly check in the reply object if pipelining
was indeed used or not. Check for the
"QNetworkRequest::HttpPipeliningWasUsedAttribute" attribute in your
reply.
Alternately, you can try and explicitly request this behaviour by
setting the n/w request attribute:
request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
If it still doesn't work, then it might be a bug. What platform are
you running your on, BTW?
HTH,
-mandeep
>
> If I simply make the second request after the first one finished like the
> following
>
> QNetworkAccessManager *manager = new QNetworkAccessManager(this);
> connect(manager, SIGNAL(finished(QNetworkReply*)),
> this, SLOT(replyFinished(QNetworkReply*)));
>
> 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.
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
More information about the Interest
mailing list