jt has asked for the wisdom of the Perl Monks concerning the following question:

I'm writting a proxy like program, upon request using http::daemon I use LWP::UserAgent to grab the file and deliver it in 4096 byte pieces. That works fine, but if the user cancels the download, I'm still sending the file. Does anyone know how to find out if the use cancels?

Replies are listed 'Best First'.
(tye)Re: Stopping Data Flow
by tye (Sage) on Apr 11, 2001 at 21:46 UTC

    If the user cancels, then the TCP connection will be closed by the user's browser which your code can then detect. Probably the easiest thing is just to check whether your print (or syswrite or whatever you are using to deliver the data) fails and terminate that request when that happens (and probably log the failure along with $! in case you end up getting failures that aren't due to user cancels).

            - tye (but my friends call me "Tye")