I have written the following simple script to control delivery of a file to a user's browser through Perl. When loading this up the user will be prompted with a "Save as..." dialog box and once they have selected a destination the file will be downloaded to their computer.
#!/usr/bin/perl
print "content-disposition: attachment; filename=\"big.bin\"\n";
print "content-type: application/octet-stream\n\n";
binmode(STDOUT);
open (DOWN, "< C:/bigfile/200m.bin"
binmode(DOWN);
print <DOWN>;
close DOWN;
This works fine for small files, even up to 10 or 20 MB but when I tested it with a 200MB file there is a vast amount of hard disk activity before either the webserver times out or the server machine crashes.
This makes me suspect that the file is being cached by the server and it appears to occur when the script is first accessed (the "Save as" dialog does not appear).
I am not sure if this is an OS, webserver or Perl issue but I have tried it in the following configurations with the same outcome:
Windows 2000+Xitami Webserver (Localhost)
Windows 2000+Apache 2.0 (Localhost)
Windows XP+Apache 1.3 (Via LAN)
RedHat Linux 8+Apache 2.0 (Localhost, Via LAN and Via web)
I have scoured the web for information about webserver caching and all evidence suggests that this is disabled by default. I have also tried a modified version of this program which reads and writes 1 byte of data at a time but this makes no difference.
Thanks.
Tyger.
#!/usr/bin/perl
print "content-disposition: attachment; filename=\"big.bin\"\n";
print "content-type: application/octet-stream\n\n";
binmode(STDOUT);
open (DOWN, "< C:/bigfile/200m.bin"
binmode(DOWN);
print <DOWN>;
close DOWN;
This works fine for small files, even up to 10 or 20 MB but when I tested it with a 200MB file there is a vast amount of hard disk activity before either the webserver times out or the server machine crashes.
This makes me suspect that the file is being cached by the server and it appears to occur when the script is first accessed (the "Save as" dialog does not appear).
I am not sure if this is an OS, webserver or Perl issue but I have tried it in the following configurations with the same outcome:
Windows 2000+Xitami Webserver (Localhost)
Windows 2000+Apache 2.0 (Localhost)
Windows XP+Apache 1.3 (Via LAN)
RedHat Linux 8+Apache 2.0 (Localhost, Via LAN and Via web)
I have scoured the web for information about webserver caching and all evidence suggests that this is disabled by default. I have also tried a modified version of this program which reads and writes 1 byte of data at a time but this makes no difference.
Thanks.
Tyger.