zlibs gzip dosent work with http
Sean Campbell via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jul 24 06:09:51 PDT 2014
I'm trying to add gzip compression to a HTTP server i wrote in D.
here is the code that dose the gzip encoding.
if ((Info.modGzip) &
(indexOf(client.getRequestHeaderFieldValue("Accept-Encoding"),"gzip")
!= -1)){
writeln("gzip");
auto gzip = new Compress(HeaderFormat.gzip);
client.addToResponseHeader("Content-Encoding: gzip");
client.sendHeader("200 ok");
while (0 < (filestream.readBlock(readbuffer))){
client.client.send(gzip.compress(readbuffer));
}
client.client.send(gzip.flush());
delete gzip;
delete filestream;
}
but when i test it Firefox, internet explorer and chrome says
that the encoding or compression is bad. why? the data is
compressed with gzip.
the rest of the code is available at
http://sourceforge.net/p/netspark/netsparkb1/ci/master/tree/
Git
git clone git://git.code.sf.net/p/netspark/netsparkb1
netspark-netsparkb1
More information about the Digitalmars-d-learn
mailing list