I'm attempting to replace the built in Gzip with this library for a WCF project I'm working on now.The code in question is derived entirely from the WCF compression sample which can be found here:
In the sample project, just replace the System.IO.Compression (which works) with Ionic.Zlib and you should see it throw an exception when decompressing a Gzipped stream. I've debugged using source and can trace it to the finish() method (in ZlibBaseStream.cs
- called by Dispose).
// workitem 8679
if (_z.AvailableBytesIn !=8)
// do an array copy of length _z.AvailableBytesIn
The problem is that in the aforementioned WCF sample, the _z.AvailableBytesIn is larger than 8 bytes. This causes an ArgumentException because the array you are trying to copy into (trailer) is only 8 bytes. I believe this is due to the way the WCF sample does
Anyway, I've attached a patch which simply changes the if statement to check for _z.AvailableBytesIn < 8. That fixed my issue and BTW I get much better compression ratios with this library than the built in System.IO.Compression. Thanks!