8 use constant CHUNK_SIZE_BYTES
=> 256;
11 my $filename = $query->param('name');
12 my $filesize = stat($filename)->size;
13 my $loadtime = $query->param('loadtime'); # in seconds
14 my $chunkcount = $filesize / CHUNK_SIZE_BYTES
;
15 my $chunkdelay = $loadtime / $chunkcount;
17 # flush the buffers after each print
21 print "Content-Type: image/png\r\n";
22 print "Expires: Thu, 01 Dec 2003 16:00:00 GMT\r\n";
23 print "Cache-Control: no-store, no-cache, must-revalidate\r\n";
24 print "Pragma: no-cache\r\n";
27 open(FILE
, $filename) or die;
32 while (($n = read FILE
, $data, CHUNK_SIZE_BYTES
) != 0) {
36 if ($total >= $filesize) {
40 # Throttle if there is some.
41 if ($chunkdelay > 0) {
42 select(undef, undef, undef, $chunkdelay);