Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compression problems
#1
I need to compress-decompress streams just before Indy transmits them.

There is a reason I want to do this manually, instead of using the Indy IdCompressionIntercept, but I still use the Indy functions:

CompressStreamEx(InStream, OutStream, clMax, zsGZip);
and
DecompressStream(InStream, OutStream);.

The problem is, the compression works perfectly, and I can save the Stream to disk, and a 3th party unzip program correctly detect the zip format, and can decompress it.

But when I call DecompressStream(InStream, OutStream), I get a "ZLib Error (-5)" in

IdZLib:

class procedure EZlibError.RaiseException(const AError: Integer);
var
  LException: EZlibError;
begin
  LException := CreateFmt(sZLibError, [AError]);
  LException.FErrorCode := AError;
  raise LException;
end;

I tried 3 different IdZLibHeaders but no difference.
I cannot find any documentation on the error, and it also does not show where it actually occurs.

Why is the Decompression not working?

Delphy 10.2.3

Bart
---
Bart Kindt
CEO and Developer
SARTrack Limited
New Zealand
www.sartrack.nz
Reply
#2
(10-16-2018, 08:34 PM)BartKindt Wrote: I need to compress-decompress streams just before Indy transmits them.

There is a reason I want to do this manually, instead of using the Indy IdCompressionIntercept

And what reason is that exactly?

(10-16-2018, 08:34 PM)BartKindt Wrote: but I still use the Indy functions:

CompressStreamEx(InStream, OutStream, clMax, zsGZip);
and
DecompressStream(InStream, OutStream);.

The problem is, the compression works perfectly, and I can save the Stream to disk, and a 3th party unzip program correctly detect the zip format, and can decompress it.

But when I call DecompressStream(InStream, OutStream), I get a "ZLib Error (-5)"

Error -5 is Z_BUF_ERROR.

(10-16-2018, 08:34 PM)BartKindt Wrote: Why is the Decompression not working?

Maybe it doesn't support GZip? If you look at the implementation of TIdCompressorZLib, its Compress methods use IndyCompressStream() (with extra parameters) and IndyDecompressStream(), whereas the Deflate methods use IndyCompressStream() (without extra parameters) and DecompressStream().

Indy's ZLib streaming has always been troublesome, to say the least. You might be best off just using the ZLib API directly in your own code.

Reply
#3
Thanks Remy,

I have found a much better solution, which you may want to consider to install in Indy instead of ZLib:

http://www.dellapasqua.com/snappy64/
https://google.github.io/snappy/

This is an extremely fast compressor, designed for streaming, and comes with files for Win32, Win63 and Android. Not sure how much work it would be to add Linux.

I have this now installed in my Client/Server system, and it works perfectly, and very very fast.

Thanks,

Bart
---
Bart Kindt
CEO and Developer
SARTrack Limited
New Zealand
www.sartrack.nz
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)