On Tuesday 12 January 2010 13:49:34 Thomas den Braber wrote: > I use Archive::Zip to generate zip files on the fly in Modperl 2.04 with > code similar like this: > > my $zip = Archive::Zip->new(); > my $member = $zip->addFile( '/home/testimg/test1.jpg', 'testfile1.jpg' ); > if ($member){ > $member->desiredCompressionLevel( 1 ); > } > $member = $zip->addFile( '/home/testimg/test2.ppt', 'testfile2.ppt' ); > if ($member){ > $member->desiredCompressionLevel( 1 ); > } > > if ( $zip->numberOfMembers() ){ > unless ( $zip->writeToFileHandle( \*STDOUT, 0) == Archive::Zip::AZ_OK) { > print STDERR "Zip error: $!"; > } > } > > This works fine with Archive::Zip version 1.26 but fails with version 1.30 > I checked the ARchibe::Zip code and could not find anything that can cause > the problem accept for the change from using Compress::Zlib to > Compress::Raw::Zlib. > > The error is: 'IO error: seeking to rewrite local header : Invalid > argument' > > If I use desiredCompressionLevel(0) then there is no problem but no > compression is done. > > The error is only related to Mod_perl. As a console script it runs fine. > Problem is on both Windows and Linux (perl 5.10).
I can only guess here but does your console script write to a pipe or to a file? Could you try: script | cat >output.zip > Has anyone any idea what might be the problem? or have an alternative > solution? > Move the ZIP file generation to a PerlFixupHandler and have it write a temporary file. Then have the default handler ship the file and remove it in a request pool cleanup or so. This has the additional benefit of sending a Content-Length header (don't forget to update $r->finfo) which often leads to faster delivery. Torsten