Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: keeping connection alive while spending time building a zip file

by Scags9876 (Novice)
on Aug 12, 2011 at 13:24 UTC ( [id://920023]=note: print w/replies, xml ) Need Help??


in reply to keeping connection alive while spending time building a zip file

Thank you all for your prompt and clear replies.

I had hoped there was some easy way around it, but I think the right way to go, as suggested by a number of you, is to have the file build in a queued, asynchronous manner, and send it to the client when it is done. This approach will take longer to implement, but it will be better in the long run for sure.

thanks again.

  • Comment on Re: keeping connection alive while spending time building a zip file

Replies are listed 'Best First'.
Re^2: keeping connection alive while spending time building a zip file
by pmqs (Friar) on Aug 12, 2011 at 15:05 UTC
    Did a quick proof of concept to see if I could stream a zip file straight to a browser while it was being created.

    The CGI script below is hard wired to create a zip file that contains the contents of two files, namely /tmp/file1 and /tmp/file2.

    use IO::Compress::Zip qw(:all) ; select STDOUT; $| = 1; my $OUT = \*STDOUT; print <<EOM; Status: 200 OK Content-Type: application/zip Transfer-Encoding: chunked EOM my @files = qw(/tmp/file1 /tmp/file2) ; zip [@files] => '-', FilterEnvelope => sub { # Chunk the output my $length = length($_); $_ = sprintf("%x", $length) . "\r\n" . $_ . "\r\n"; $_ .= "\r\n" unless $length; 1; } ;
    Whether this helps in your use-case is depends on where the 10 minute delay comes from. If the delay is CPU/network related, this may help a bit, but it probably won't solve the issue for you.

    Anyway, had created the code written, so thought I'd share it with you.

Re^2: keeping connection alive while spending time building a zip file
by lkrishnan (Initiate) on May 06, 2015 at 15:31 UTC
    is there a solution for this? kindly share if this has been resolved

      is there a solution for this? kindly share if this has been resolved

      A solution for what?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://920023]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-20 04:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found