Thread Probleme mit Compress::Zlib::memGzip (12 answers)
Opened by burnersk at 2008-07-15 16:13

GwenDragon
 2008-07-15 18:16
#112153 #112153
User since
2005-01-17
14816 Artikel
Admin1
[Homepage]
user image
Mein Skript sendet brav den gzip-Stream an den Browser.
Code: (dl )
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
#!/usr/bin/perl 
use strict;
use warnings;
use Compress::Zlib;
use Digest::MD5 qw(md5_hex);
use Data::Dumper;
my $now = "Tue, 15 Jul 2008 12:06:38 GMT";
my $content = '';
$content .= "$_ test test test test test \n" for (1..1000);
my $b = Compress::Zlib::memGzip("$content") or die("Compression: $!");
my $l = length($b) or die ('buffer has no length');
my $md5 = md5_hex($b) or die ('md5 not calculated');
print <<HTTP;
Allow: GET, POST
Connection: close
Content-Encoding: gzip
Content-Length: $l
Content-MD5: $md5
Content-Type: text/plain
Date: $now
Last-Modified: $now

HTTP
binmode(STDOUT);
print("$b");

my $log;
if (open($log, '>', '/tmp/z.log')) {
binmode($log);
print $log $b;
close($log);
}

Im Log kannst du sehen, dass der Inhalt Gzip-kodiert ist.
Die Magic-Bytes für Gzip sind nämlich: \x1f\x1b
http://schmidt.devlib.org/file-formats/gzip-archiv...

View full thread Probleme mit Compress::Zlib::memGzip