I can't seem to get a stream that Flex 3 want's to decompress.
I've tried:
- System.IO.Compression.GZipStream
- System.IO.Compression.DeflateStream
- ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream
- zlib.ZOutputStream
None of these seem to make ByteArray.uncompress
happy, i.e. I get
Error #2058: There was an error decompressing the data.
Also the whole Deflate vs zlib has me going around in circles.
It seems that according to the wikipedia article, zlib is an implementation of DEFLATE. But according to Actionscript they are two different things?
Microsoft also seems to indicate the Gzip at least uses the Deflate algorithm, as in their docs they refer that GZipOutputStream uses the same compression algorithm as DeflateStream. So I'm assuming that it's just a header difference, which would indicate that's "no good" as far as 'ByteArray.uncompress' as the "DEFLATE" algorithm is only supported in AIR applications.
Sample "server" code, using SharpZipLib in this case (not working):
public virtual bool ProcessRequest(string path, HttpListenerContext context)
{
var buffer = File.ReadAllBytes(path);
// Specifying to strip header/footer from data as that seems to be what the
// docs for ByteArray.uncompress indicate is necessary
var deflater = new Deflater(Deflater.DEFAULT_COMPRESSION, true);
using (var zipStream = new DeflaterOutputStream(context.Response.OutputStream, deflater))
{
zipStream.Write(buffer, 0, buffer.Length);
}
}