[fpc-pascal] From deflate to gzip

silvioprog silvioprog at gmail.com
Tue Apr 1 08:38:00 CEST 2014


Hello,

I'm using gzip from Apache to compress my static files (like HTML, CSS, JS
etc.), and it worked fine (http://imagebin.org/303024). But, to compress
the CGI content, I'm using deflate:

var
  m: TMemoryStream;
begin
  if aeDeflate in BrookGetAcceptEncodingSet(ARequest.AcceptEncoding) then
  begin
    m := TMemoryStream.Create;
    try
      with TCompressionStream.Create(clMax, m, True) do
      try
        Write(AResponse.Content[1], Length(AResponse.Content));
      finally
        Free;
      end;
      m.Seek(0, 0);
      AResponse.SetCustomHeader(fieldContentEncoding, 'deflate');
      AResponse.ContentStream := m;
      AResponse.SendContent;
     finally
      m.Free;
    end;
  end;
end;

Now I need to use gzip instead of deflate, like:

      AResponse.SetCustomHeader(fieldContentEncoding, 'gzip');

So, how to use zstream to (or other) to compress my content stream in gzip
mode? I need to create a temporary gzip file (using TGZFileStream class)
and load it after from my stream (m), or I can do it directly in stream?

Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140401/5b85831b/attachment.html>


More information about the fpc-pascal mailing list