[Interest] QNetworkAccessManager and HTTP persistent connection
mandeepsandhu.chd at gmail.com
Wed Nov 27 09:27:22 CET 2013
Please reply to the whole list and not to me individually. Maybe
someone on this list might have a more specific answer.
Both pipelined and persistent connections use a single TCP connection.
But in pipelining, the client can send multiple requests WITHOUT
WAITING for a response from the server whereas in persistent
connections the second (or subsequent) responses are sent only after
receiving response of the previous request:
If the server has not sent a "Connection: Close" then closing the
connection from the client _might_ to be a bug.
How are you ascertaining that the client is initiating the close? Does
the packet sniffer show the client sending a FIN packet?
On Wed, Nov 27, 2013 at 12:21 PM, iMath <2281570025 at qq.com> wrote:
> HTTP persistent connection, also called HTTP keep-alive, or HTTP connection
> reuse, is the idea of using a single TCP connection to send and receive
> multiple HTTP requests/responses, as opposed to opening a new connection for
> every single request/response
> "Connection:keep-alive" is in the response header.
> 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
> ------------------ Original ------------------
> From: "Mandeep Sandhu";<mandeepsandhu.chd at gmail.com>;
> Date: Tue, Nov 26, 2013 08:50 PM
> To: "iMath"<2281570025 at qq.com>;
> Cc: "Interest at qt-project.org"<interest at qt-project.org>;
> Subject: Re: [Interest] QNetworkAccessManager and HTTP persistent
> I think I was wrong in telling you that HTTP persistent connection was
> same as HTTP pipelining. They aren't.
> In HTTP pipelining multiple HTTP requests can be made w/o waiting for
> response of each connection. Whereas in HTTP persistent connection
> (default as you said in HTTP 1.1), the same TCP connection is used for
> sending HTTP request "one-after-another".
> Can you check if the the outgoing HTTP request has the "Connection:
> keep-alive" set in its (HTTP) header. Also, I've read that sometimes
> webservers will send a "Connection: Close" header in its response in
> which case the client will close it's connection, so check if the
> webserver is playing nice with your request. Which webserver are you
> testing against?
> On Tue, Nov 26, 2013 at 5:19 PM, iMath <2281570025 at qq.com> wrote:
>> unfortunately ,it doesn't work on Qt4/WinXP
>> I have set
>> but the attribute QNetworkRequest::HttpPipeliningWasUsedAttribute in the
>> reply is false .
>> ------------------ Original ------------------
>> From: "Mandeep Sandhu";<mandeepsandhu.chd at gmail.com>;
>> Date: Tue, Nov 26, 2013 02:14 PM
>> To: "iMath"<2281570025 at qq.com>;
>> Cc: "interest"<interest at qt-project.org>;
>> Subject: Re: [Interest] QNetworkAccessManager and HTTP persistent
>> 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
>>> second http request using the same connection that was setup when the
>>> 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
>> Alternately, you can try and explicitly request this behaviour by
>> setting the n/w request attribute:
>> If it still doesn't work, then it might be a bug. What platform are
>> you running your on, BTW?
>>> If I simply make the second request after the first one finished like the
>>> QNetworkAccessManager *manager = new QNetworkAccessManager(this);
>>> connect(manager, SIGNAL(finished(QNetworkReply*)),
>>> this, SLOT(replyFinished(QNetworkReply*)));
>>> 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
>>> Interest mailing list
>>> Interest at qt-project.org
More information about the Interest