[fpc-pascal] From deflate to gzip

2014-04-01 Thread silvioprog
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
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] From deflate to gzip

2014-04-01 Thread Michael Van Canneyt



On Tue, 1 Apr 2014, silvioprog wrote:


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?


No, currently you need a file, unless you are willing to duplicate the 
tgzstream class using an in memory-approach.
(that would be a welcome addition, BTW)

Michael.___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] minigzip example does not compile (?)

2014-04-01 Thread Juha Manninen
I also have a gzip related issue.
I try to test with paszlib/examples/minigzip but the compiler gives :

minigzip.pas(73,40) Error: Call by var for arg no. 2 has to match
exactly: Got LongInt expected SmallInt

FPC 2.6.4 and FPC trunk seem to have identical code here.

It is possible I do something stupid. Should I add compiler flags?

Regards,
Juha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] minigzip example does not compile (?)

2014-04-01 Thread Juha Manninen
Another note about paszlib sources. There is a spelling mistake in the
header comment which is copied to every source file:
 Pascal tranlastion

Juha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] minigzip example does not compile (?)

2014-04-01 Thread Juha Manninen
On Tue, Apr 1, 2014 at 11:09 AM, Juha Manninen
juha.mannine...@gmail.com wrote:
 Got LongInt expected SmallInt

I opened the example program in Lazarus for debugging it.
Lazarus project uses mode objfpc by default. Changing 2 variables from
Integer to SmalInt solved the compilation problem.
IMO the type should be corrected as debugging with Lazarus is often a good idea.

Juha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] minigzip example does not compile (?)

2014-04-01 Thread Michael Van Canneyt



On Tue, 1 Apr 2014, Juha Manninen wrote:


On Tue, Apr 1, 2014 at 11:09 AM, Juha Manninen
juha.mannine...@gmail.com wrote:

Got LongInt expected SmallInt


I opened the example program in Lazarus for debugging it.
Lazarus project uses mode objfpc by default. Changing 2 variables from
Integer to SmalInt solved the compilation problem.
IMO the type should be corrected as debugging with Lazarus is often a good idea.


Or we add a {$mode fpc} to the sources.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] minigzip example does not compile (?)

2014-04-01 Thread Juha Manninen
BTW, does anybody know of a Delphi compatible version of this compression lib?
The new Unicode Delphis do not need to be supported.
What about some other similar Delphi compatible lib?

Juha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] minigzip example does not compile (?)

2014-04-01 Thread Marco van de Voort
In our previous episode, Juha Manninen said:
 BTW, does anybody know of a Delphi compatible version of this compression lib?
 The new Unicode Delphis do not need to be supported.
 What about some other similar Delphi compatible lib?

Newer delphi's come with a zstream iirc, and contrary to D7(*), you don't need
to do anything. (unit zlib, tzcompressionstream and -de variant + helper
procedures). I use them for the png compression in my ported fcl-image parts.

(*) IIRC, long time ago
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] minigzip example does not compile (?)

2014-04-01 Thread Juha Manninen
On Tue, Apr 1, 2014 at 1:53 PM, Marco van de Voort mar...@stack.nl wrote:
 Newer delphi's come with a zstream iirc, and contrary to D7(*), you don't need
 to do anything. (unit zlib, tzcompressionstream and -de variant + helper
 procedures). I use them for the png compression in my ported fcl-image parts.

Yes but we still have Delphi 2007.
It only has TCompressionStream but no TZCompressionStream.
Maybe we could just add our own metadata wrapper instead of gzip or a
zlib wrapper.
Well, it does not sound like a clever thing to do.

We have used tpabbrevia but it has a bug with very big files (like 6
GB). Its code is not easy to understand and I would rather not start
searching the bug.

Marco, what was the FPC counterpart for TZCompressionStream in your
Delphi-compatible code? FPC does not have TZCompressionStream either.

Juha
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] From deflate to gzip

2014-04-01 Thread Daniel Gaspary
On Tue, Apr 1, 2014 at 4:12 AM, Michael Van Canneyt
mich...@freepascal.org wrote:
 No, currently you need a file, unless you are willing to duplicate the
 tgzstream class using an in memory-approach.
 (that would be a welcome addition, BTW)

TZipper has similar problem, you cannot write direct to the destination file.

Months a go I worked to modify the class to have a Stream writing
directly to a zip file.

A complicated change, and I don't know if worth the effort because due
to Zip format[1], I realize that only streams with support to seek
back would be possible.

[1] The File Header is written before the compressed stream, and it
must contain the compressed file size.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] From deflate to gzip

2014-04-01 Thread silvioprog
2014-04-01 4:12 GMT-03:00 Michael Van Canneyt mich...@freepascal.org:
[...]

 No, currently you need a file, unless you are willing to duplicate the
 tgzstream class using an in memory-approach.
 (that would be a welcome addition, BTW)


Nice, I'll analize the possibility to implement it.

-- 
Silvio Clécio
My public projects - github.com/silvioprog
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Free pascal candidate for project of the month

2014-04-01 Thread Martin Frb

On 26/03/2014 20:44, Marco van de Voort wrote:

FYI:

Free Pascal is candidate for SF project of the month april, up against
strong candidates as subversion for windows (the server, not tortoise) and
smplayer.

Note that you need a SF login to vote:

https://sourceforge.net/p/potm/discussion/vote/thread/c38203c8/



Should we make an announcement on the forum?  Not everyone is on the 
mail list.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] minigzip example does not compile (?)

2014-04-01 Thread Marco van de Voort
In our previous episode, Juha Manninen said:
 Maybe we could just add our own metadata wrapper instead of gzip or a
 zlib wrapper.
 Well, it does not sound like a clever thing to do.
 
 We have used tpabbrevia but it has a bug with very big files (like 6
 GB). Its code is not easy to understand and I would rather not start
 searching the bug.
 
 Marco, what was the FPC counterpart for TZCompressionStream in your
 Delphi-compatible code? FPC does not have TZCompressionStream either.

Afaik I use the zstream ones.

I do know from zipfile component that there are two forms of inflate/deflate
(which is also zlib), one with a header before, and one with a header
appended (the streaming variant)
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Free pascal candidate for project of the month

2014-04-01 Thread Marco van de Voort
In our previous episode, Martin Frb said:
  Free Pascal is candidate for SF project of the month april, up against
  strong candidates as subversion for windows (the server, not tortoise) and
  smplayer.
 
  Note that you need a SF login to vote:
 
  https://sourceforge.net/p/potm/discussion/vote/thread/c38203c8/
 
 Should we make an announcement on the forum?  Not everyone is on the 
 mail list.

Go ahead!
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal