Re: [Catalyst] Detecting if a user aborted a (long) download
There are various compromises that you can make instead, including checking to see if the whole file at least made it out of your catalyst app (by having your filehandle monitor that for you). You can also give the user a good amount of time to download the file as many times as he likes (bandwidth is cheap), or you can have customer support allow the user to re-download if he complains (Apple does this). You are free to ignore all of the above advice. It isn't my problem. I agree with the above advice, you may also note that if you are charging for the downloads there may be legal/accounting reasons for this method (that almost all electronic delivery systems use). Technically, if you deliver only over the internet you need to have a certain level of backup to prove that the product was delivered or that the client had the ability to receive the product (and request it again if she states that she was unable to receive it) in many countries to be able to show revenue on your books. It may be worth your while to have both an accountant that specializes in Internet delivery/booking and a lawyer give you some guidance about what is required in your area to cover your bases. -Wade ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
Jonathan Rockway wrote: On Sunday 11 March 2007 21:18, Jeff Chimene wrote: Jonathan Rockway wrote: On Sunday 11 March 2007 20:59, Jeff Chimene wrote: How does that differ from something that compares bytes sent to bytes received? Assuming that the OP defines success when bytes received = bytes sent How do you determine how many bytes were received and successfully written to disk? There's also this: http://ajaxpatterns.org/Progress_Indicator#What_sort_of_progress_indicato r_will_you_use.3F I think this thread has wandered a bit off topic. That's hardly for you to decide, now is it? We are talking about how to ensure that a user has reliably downloaded and is able to access (from his own machine) an mp3 file. No, you are. The original question was I need to figure out if a user aborted a longish download. The answer is that you can't do that without asking the user :) To that question, you are correct. But, that's not the question. There are various compromises that you can make instead, including checking to see if the whole file at least made it out of your catalyst app (by having your filehandle monitor that for you). You can also give the user a good amount of time to download the file as many times as he likes (bandwidth is cheap), or you can have customer support allow the user to re-download if he complains (Apple does this). You are free to ignore all of the above advice. It isn't my problem. Then why bother to reply? Since we haven't heard from the OP. I have two questions: o Did you investigate sendfile? o Have you considered implementing a download progress indicator? One of the reasons users give up on downloads is that they don't know what's happening. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
Since we haven't heard from the OP. I have two questions: o Did you investigate sendfile? Sendfile() buys you nothing relevant to the OP's question. o Have you considered implementing a download progress indicator? One of the reasons users give up on downloads is that they don't know what's happening. What browser are you using that does not: 1, have its own download session manager + progress display 2, where download app continues download even if you leave the page/site that started it 3, and the browser tells you hey numbnuts, you are still downloading are you sure you want to close? when you try to close your browser before the download is complete. 4, where a separate download progress bar that is non standard would be anything but confusing to a user? The bottom line is, downloads break sometimes for many reasons. Your app (being on the server) will never be able to know if the download completes or not unless you control the download end-to-end (such as writing and distributing your own download manager). A silly progress bar embedded in your webapp does not get you past this problem. A simple, smart and quite frankly the industry standard solution is to allow the user to try again on failure. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
On Mon, 12 Mar 2007, [EMAIL PROTECTED] wrote: 2, where download app continues download even if you leave the page/site that started it This is normal behavior. In Firefox, at least, once you start downloading the file, that's a separate request, unrelated to the page where I started the download. IIRC, IE has the same behavior. -dave /*=== VegGuide.Orgwww.BookIRead.com Your guide to all that's veg. My book blog ===*/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
Hi Thomas, Check out the code associated with the 2006 advent calendar entry entitled 'streaming mp3s with Catalyst' http://www.catalystframework.org/calendar/2006/15 It's a little more involved, in that it handles 'range' requests - but the main portion of the mp3 sending should work for you, you'd just have to add a byte counter and compare when the writing is finished if all the data was sent or not. The code you are interested in is lib/Streaming.pm - 'sub mp3 : Local' That should get you most of what you need with some well chosen hackery. As an aside - I don't know what you are doing with this - but in terms of charging based on whether the file was downloaded in it's entirety - with mp3s you can drop off the end usually without it affecting playback much, if at all. In other words - expect that people will figure out the billing method and stop the download just a few bytes shy of the end of the file to avoid paying. (I've seen automated bookmarklet things that do just that) Just something to be aware of. Jay On Mar 11, 2007, at 9:26 AM, Thomas Klausner wrote: Hi! I need to figure out if a user aborted a longish download. (some background: Users can download a limited amount of mp3s. If the download doens't work for some reason, they must not be charged) In our old plain mod_perl 1.x handlers, I had something like: $r-send_fd($fh); if ($r-connection-aborted) { # do stuff if user aborted download } Now, using Catalyst (on mod_perl 2.x), I'm doing this to send the file: $c-res-body( $fh ); But how do I figure out if the download was successfull? I didn't find anything in the docs (but a RTFM-answer is appreciated, if I missed the right piece of codocumentation). Thanks! -- #!/usr/bin/perl http://domm.zsi.at for(ref bless{},just'another'perl'hacker){s-:+-$-gprint$_.$/} ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/ catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/ --- May we not return to those scoundrels of old, the illustrious founders of superstition and fanaticism, who first took the knife from the altar to make victims of those who refused to be their disciples. - Voltaire ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
Hi! On Mon, Mar 12, 2007 at 01:21:45PM -0500, [EMAIL PROTECTED] wrote: your webapp does not get you past this problem. A simple, smart and quite frankly the industry standard solution is to allow the user to try again on failure. So I need to figure out if there was I failure. Which I did (in modperl 1.x) using $r-connection-aborted. I'm still not sure if sendfile() does the same, but it seems to do. Or I can use $c-write, as in the Streaming.pm example suggested by Jay. -- #!/usr/bin/perl http://domm.zsi.at for(ref bless{},just'another'perl'hacker){s-:+-$-gprint$_.$/} ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
[EMAIL PROTECTED] wrote: Since we haven't heard from the OP. I have two questions: o Did you investigate sendfile? Sendfile() buys you nothing relevant to the OP's question. Really? The OP was merely detecting whether or not the session aborted, not whether or not the file successfully downloaded. Apparently sendfile() can return an error condition related to the OP's original design. The point is it does not. Welcome to the Internet where AOL's (google, netspeed, isp X with SpeedupPro tech, or that silly corporate office) proxy server/firewall/virus proxy has just soaked up the full download (no sendfile or io dispatcher error) and the client only got half. The OP's assumption and initial implementation is obviously broke. Handing him a Jack to fix his airplane wing he is describing as a flat tire is a disservice. o Have you considered implementing a download progress indicator? One of the reasons users give up on downloads is that they don't know what's happening. What browser are you using that does not: 1, have its own download session manager + progress display 2, where download app continues download even if you leave the page/site that started it 3, and the browser tells you hey numbnuts, you are still downloading are you sure you want to close? when you try to close your browser before the download is complete. 4, where a separate download progress bar that is non standard would be anything but confusing to a user? The bottom line is, downloads break sometimes for many reasons. Your app (being on the server) will never be able to know if the download completes or not unless you control the download end-to-end (such as writing and distributing your own download manager). A silly progress bar embedded in your webapp does not get you past this problem. A simple, smart and quite frankly the industry standard solution is to allow the user to try again on failure. It's not clear to me that the OP is using a browser, vs. some custom application that relies on HTTP protocol. Since the OP hasn't chimed in on this thread, I'm done answering these questions. We were told enough information to know that the implementation was broken and we are offering valid (unbroken or not-so-broke) alternatives. And as another poster said: The advice is free -- take it or leave it. ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
Here's a worst-case scenario you send it to IE and somewhere along the line it picks up a Vary header. IE won't store anything in it's cache with a Vary header - not even downloaded files. So it downloads the file then deletes it. You can't save it elsewhere or retrieve it! http://support.microsoft.com/?kbid=824847 (By the way it exhibits the same behaviour if you send proper no-cache headers.) So as far as the server is concerned, your logs are concerned, and anything else you are concerned that file has been delivered to the client successfully. As far as the user is concerned you may as well not have bothered as the browser's eaten the download. Carl ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
On Sunday 11 March 2007 09:26, Thomas Klausner wrote: But how do I figure out if the download was successfull? I didn't find anything in the docs (but a RTFM-answer is appreciated, if I missed the right piece of codocumentation). You probably want a subclass of IO::File that will callback into your application as the file is streamed. Keep in mind that this won't account for buffering between the app and webserver, the webserver and the load balancer, the load balancer and the user's ISP's front-end proxy, the user's ISP's front-end proxy and the user's TCP stack, the user's TCP stack and the web browser, the web browser and disk cache, and finally the disk cache and the user's disk. Not as simple as it seems, is it? :) You'd be better off just letting the user download the file as many times as it takes for, say, a week. Regards, Jonathan Rockway -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; pgp9lU3t4ZQUV.pgp Description: PGP signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
Jonathan Rockway wrote: On Sunday 11 March 2007 09:26, Thomas Klausner wrote: But how do I figure out if the download was successfull? I didn't find anything in the docs (but a RTFM-answer is appreciated, if I missed the right piece of codocumentation). You probably want a subclass of IO::File that will callback into your application as the file is streamed. Keep in mind that this won't account for buffering between the app and webserver, the webserver and the load balancer, the load balancer and the user's ISP's front-end proxy, the user's ISP's front-end proxy and the user's TCP stack, the user's TCP stack and the web browser, the web browser and disk cache, and finally the disk cache and the user's disk. Not as simple as it seems, is it? :) You'd be better off just letting the user download the file as many times as it takes for, say, a week. Regards, Jonathan Rockway How does that differ from something that compares bytes sent to bytes received? Assuming that the OP defines success when bytes received = bytes sent ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
On Sunday 11 March 2007 20:59, Jeff Chimene wrote: How does that differ from something that compares bytes sent to bytes received? Assuming that the OP defines success when bytes received = bytes sent How do you determine how many bytes were received and successfully written to disk? -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; pgpqrXAAAYk87.pgp Description: PGP signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
Jonathan Rockway wrote: On Sunday 11 March 2007 20:59, Jeff Chimene wrote: How does that differ from something that compares bytes sent to bytes received? Assuming that the OP defines success when bytes received = bytes sent How do you determine how many bytes were received and successfully written to disk? content-length header = received whatever-writes-on-the-client-side = written ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
Jonathan Rockway wrote: On Sunday 11 March 2007 20:59, Jeff Chimene wrote: How does that differ from something that compares bytes sent to bytes received? Assuming that the OP defines success when bytes received = bytes sent How do you determine how many bytes were received and successfully written to disk? There's also this: http://ajaxpatterns.org/Progress_Indicator#What_sort_of_progress_indicator_will_you_use.3F ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Detecting if a user aborted a (long) download
On Sunday 11 March 2007 21:18, Jeff Chimene wrote: Jonathan Rockway wrote: On Sunday 11 March 2007 20:59, Jeff Chimene wrote: How does that differ from something that compares bytes sent to bytes received? Assuming that the OP defines success when bytes received = bytes sent How do you determine how many bytes were received and successfully written to disk? There's also this: http://ajaxpatterns.org/Progress_Indicator#What_sort_of_progress_indicato r_will_you_use.3F I think this thread has wandered a bit off topic. We are talking about how to ensure that a user has reliably downloaded and is able to access (from his own machine) an mp3 file. The answer is that you can't do that without asking the user :) There are various compromises that you can make instead, including checking to see if the whole file at least made it out of your catalyst app (by having your filehandle monitor that for you). You can also give the user a good amount of time to download the file as many times as he likes (bandwidth is cheap), or you can have customer support allow the user to re-download if he complains (Apple does this). You are free to ignore all of the above advice. It isn't my problem. -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; pgpQXvHvEUV3i.pgp Description: PGP signature ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/