Returning large binary to browswer via CGI
Returning large binary to browswer via CGI
(OP)
I have a fairly simple perl cgi script that generates a large ISO file (4GB). Perl is working fine from a CGI perspective because simple html generated by the perl cgi works fine. When executed at the shell, the perl script generates the large ISO file perfectly. However, when run via cgi, what is returned to the browser is a small 34k file.
I suspect either a timeout from apache, a size limitation, or both.
The html generated by perl is as follows:
Content-type: application/octet-stream;
Content-Disposition: attachment; filename="kickstart.iso"
Content-Transfer-Encoding: binary
The binary data follows immediately
I'm fairly green at HTML/CGI so any assistance might be appreciated.
I suspect either a timeout from apache, a size limitation, or both.
The html generated by perl is as follows:
Content-type: application/octet-stream;
Content-Disposition: attachment; filename="kickstart.iso"
Content-Transfer-Encoding: binary
The binary data follows immediately
I'm fairly green at HTML/CGI so any assistance might be appreciated.
RE: Returning large binary to browswer via CGI
Hard to say anything as you posted no CGI code so far.
Anyway, a generic advice : if not using the CGI module, try to set binmode.
Feherke.
http://feherke.github.com/
RE: Returning large binary to browswer via CGI
#!/usr/bin/perl
print "Content-type: application/octet-stream\n";
print "Content-Disposition: attachment\; filename=\"kickstart.iso\"\n";
print "Content-Transfer-Encoding: binary\n\n";
binmode(STDOUT);
exec("mkisofs -r -T -J -V \"Redhat KSBoot\" -b pub/isolinux/isolinux.bin -c pub/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -v .");
RE: Returning large binary to browswer via CGI
I was able to reproduce the problem.
But I am quite sure the problem is not with the transfer. If I redirect exec("mkisofs --all-that-stuff > /tmp/dolfantimmy.iso");, the resulted file will be also 34816 byte long.
As mkisofs's STDERR is not redirected, it gets written to the web server's error log file. There is a line :
If I set write permission on the pub/isolinux/ directory and the isolinux.bin file for the web server's user, the error message disappears and the downloaded file's size seems to be correct.
I have no experience with mkisofs, but I would give a try to the above.
Feherke.
http://feherke.github.com/
RE: Returning large binary to browswer via CGI
I suspect you have a permissions issue on your side. The above perl script is called iso.pl If I execute the following....
perl ./iso.pl > foo.iso
a 4GB is generated as I would suspect.
RE: Returning large binary to browswer via CGI
Also if you su - webserveruser first ? ( I mean, become to user with who's permissions the web server runs. Search the configuration files for User directive to find out the given user. )
Feherke.
http://feherke.github.com/
RE: Returning large binary to browswer via CGI
RE: Returning large binary to browswer via CGI
You mean, you have a User root directive in your web server configuration ? You read the warning before setting that, right ?
( Apache HTTP Server Version 2.2 Documentation | Apache MPM Common Directives | User Directive )
Anyway, one thing you can still do : check your web server's logs.
Feherke.
http://feherke.github.com/
RE: Returning large binary to browswer via CGI
I must have overlooked your suggestion regarding the write bit on isolinux directory isolinux.bin file. That solved the problem. Thanks a TON!!!