views:

1170

answers:

5

I am upgrading a app to Delphi 2009. The app uses Soap and we compress the soap request and response streams using Zlib. This works fine in Delphi 2006 but not in Delphi 2009.

So I went back to Delphi 2006 and changed to use FastZlib. It all worked fine in Delphi2006 but does not work in Delphi 2009 and I get Decompress errors.

Has anyone else had this problem?

How do I go about fixing this?

Sandeep

A: 

I just looked through the built-in Zlib.pas and it appears to have been updated for D2009 properly. What's giving you problems?

Mason Wheeler
A: 

When I run the app compiled in Delphi2009 I get

EZDecompressionError with message 'data error'

I am using the latest version of FastZlib.

The built in Zlib had CompressBuf and DecompressBuf in Delphi 2006 but seem to be missing in Delphi2009.

A: 

In delphi 2006 I had following methods to compress and decompress using Zlib(from Delphi 2006)

procedure CompressStream(inpStream, outStream: TStream);
var
  InpBuf, OutBuf: Pointer;
  InpBytes, OutBytes: Integer;
begin
  InpBuf := nil;
  OutBuf := nil;
  try
    GetMem(InpBuf, inpStream.Size);
    inpStream.Position := 0;
    InpBytes := inpStream.Read(InpBuf^, inpStream.Size);
    CompressBuf(InpBuf, InpBytes, OutBuf, OutBytes);
    outStream.Write(OutBuf^, OutBytes);
  finally
    if InpBuf <> nil then FreeMem(InpBuf);
    if OutBuf <> nil then FreeMem(OutBuf);
  end;
end;


{ Decompress a stream }
procedure DecompressStream(inpStream, outStream: TStream);
var
  InpBuf, OutBuf: Pointer;
  OutBytes, sz: Integer;
begin
  InpBuf := nil;
  OutBuf := nil;
  sz     := inpStream.Size - inpStream.Position;
  if sz > 0 then 
    try
      GetMem(InpBuf, sz);
      inpStream.Read(InpBuf^, sz);
      DecompressBuf(InpBuf, sz, 0, OutBuf, OutBytes);
      outStream.Write(OutBuf^, OutBytes);
    finally
      if InpBuf <> nil then FreeMem(InpBuf);
      if OutBuf <> nil then FreeMem(OutBuf);
    end;
  outStream.Position := 0;
end;

What should I change for these to work in Delphi 2009?

A: 

Something that might be worth trying - compress your data, and then UUENCODE it, and on the other end, reverse the process. This will detect if some code is not dealing with embedded zero's properly.

Sorry, this is only a partial solution to help you narrow the problem down.

A: 

The original poster's was clear about the problem: CompressBuf and DecompressBuf are GONE.

I also have a project that compiles just fine in D7, but fails to compile in D2010 because it can't find "CompressBuf" or "DecompressBuf".

A search using D7's very pleasant find command locates the routines at c:\Program Files\Borland\Delphi7\Source\Rtl\Common\ZLib.pas

But searching with D2010's (awkward separate) "Find in Files" command fails to locate CompressBuf or DecompressBuf anywhere.

It's very disturbing that upgrading the IDE causes routines used and needed in projects to disappear!

Kevin Killion