Leser: 35
1 2 3 4 5 6
print "Content-Type: application/octet-stream;\r\n"; print "Accept-Ranges: bytes\r\n"; print "Content-Length: " . length ($content) . "\r\n"; print "Content-Disposition: attachment; filename=\"$datname\""; print "\r\n\r\n"; print $content;
2009-11-23T14:07:35 pqhast du es mal mit anderen browsern getestet?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#!/usr/bin/perl use strict; use warnings; use CGI qw(); # Testdaten my $content = '0123456789abcdef' x ( 64 * 1024 ); my $cgi = CGI->new(); print $cgi->header( -type => 'application/octet-stream', -attachment => 'save.dat', # -Content_length => length $content, ); ### Altlasten #my $length = length $content; #print <<OUTPUT; #Content-Type: application/octet-stream #Content-Length: $length #Content-Disposition: attachment; filename="save.dat" # #OUTPUT my $pos = 0; my $partlength = 10_240; # langsamen Download simulieren; (wg. Test mit localhost) while ( my $part = substr( $content, $pos, $partlength ) ) { print $part; $pos+=$partlength; sleep 1; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
$| = 1; # Pufferung aus my $content = '0123456789abcdef' x ( 64 * 1000 ); # Blödsinn erzeugen print "Content-Type: application/octet-stream\n"; # Header 1 print "Content-length: " . length ($content) . "\n"; # Header 2 print "Content-Disposition: attachment; filename=\"testdatei.bin\""; # Header 3 print "\n\n"; # Ausgabe verzögern, damit das Problem noch deutlicher wird: my $pos = 0; my $partlength = 20_480; while ( my $part = substr( $content, $pos, $partlength ) ) { print $part; $pos+=$partlength; sleep 1; }
1 2 3 4 5 6
print $q -> header ( -type => 'application/octet-stream', -attachment => $attfeld[0], -Content_Range => 'bytes', -Content_length => length $content, );
Content-Range => 'bytes 0-499/1234' # bei den Bytes 0..499
-Content_Range => "bytes 0-".length($content)."/".length($content)."\r\n";