[Qt-interest] cancel http requests

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Fri Aug 26 07:49:42 CEST 2011


On Thu, Aug 25, 2011 at 8:12 PM, Atlant Schmidt
<aschmidt at dekaresearch.com> wrote:
> Mandeep:
>
>  But that doesn't actually have any effect on the
>  server, does it? There's no way in the HTTP protocol

Atlant, the answer is dependent on what the server does with your
request. If you're requesting for small chunks of data, then probably
it does not help the server much. Consider the case that your Qt
client is requesting a big image file (~2MB) via HTTP. When the server
gets the request, it will try to send back the image data to the
client. Now if a client aborts mid-way, I assume this will result in a
TCP connection being torn down, the server will come to know of a
client disconnect and it can then abort the file transfer operation.

And in some cases it might be doing something even more complex, so an
abort from the client side would always help, I think. Any socket
freed on the server end will only make it happier! :) (and would
probably free up a request handling thread too).

Also, if you're using a HTTP 1.1, it defaults to persistent
connection, so this might also act as indication to the server to not
keep the connection with the client, open.

>  to cancel an in-flight request; one can just ignore
>  the data returned by the server.

Ummm...not sure here, because an HTTP request is nothing but writing
strings to a open TCP socket. Now if we abort half-way through this
op, then maybe the we are aborting an in-flight request. Just
speculating as I haven't seen actual Qt code. CMIIW.

>
>  It's not nice, of course, to set the server working
>  on a bunch of stuff one will end up ignoring; the
>  server probably has other clients who are waiting.

True.

And I agree that a better thing to do would be to not to send out the
request in the first place.

Regards,
-mandeep


>
>                               Atlant
>
> -----Original Message-----
> From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of Mandeep Sandhu
> Sent: Thursday, August 25, 2011 10:01
> To: Sergey
> Cc: qt-interest at qt.nokia.com
> Subject: Re: [Qt-interest] cancel http requests
>
>> Is it possible to cancel some of previous http requests on the client
>> side, so that server would not serve them?
>
> It is, if you have a handle to QNetworkReply object that was returned
> in your get/post method call (QNAM::get/post);
>
> http://doc.qt.nokia.com/latest/qnetworkreply.html
>
> You can call QNetworkReply::abort() to cancel the pending request.
>
> HTH,
> -mandeep
>
>>
>> --
>> Thanks!
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at qt.nokia.com
>> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
> This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
>
> Thank you.
>
> Please consider the environment before printing this email.
>



More information about the Qt-interest-old mailing list