I need to decompress data inside MIME message. Data marked with compressed-data
Here is code I tried:
using (var msi = new MemoryStream(content))
using (var mso = new MemoryStream())
{
using (var gs = new GZipStream(msi, CompressionMode.Decompress))
gs.CopyTo(mso);
var a = mso.ToArray();
}
Getting exception:
Found invalid data while encoding at System.IO.Compression.InflaterZlib.Inflate(FlushCode flushCode) at System.IO.Compression.InflaterZlib.ReadInflateOutput(Byte[] outputBuffer, Int32 offset, Int32 length, FlushCode flushCode, Int32& bytesRead) at System.IO.Compression.InflaterZlib.Inflate(Byte[] bytes, Int32 offset, Int32 length) at System.IO.Compression.DeflateStream.Read(Byte[] array, Int32 offset, Int32 count) at System.IO.Compression.GZipStream.Read(Byte[] array, Int32 offset, Int32 count) at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize) at System.IO.Stream.CopyTo(Stream destination)
I know it's GZIP in this block of data (per RFC). Ok, I asked question here
CodePudding user response:
i don't known CmsCompressedDataParser, but c you image, i sure that are not gzip or deflater data. gzip must start with 0x8B 0x1F, deflater first byte low 4bit must 0x8 for example 0x78
u can try two option, first, in java byte order is BE, in c# you need try byte order as BE too
second, deflater may work on no wrap mode, mean the magic flag (first 2 bytes) and CRC data will not output, so i say that not gzip/deflater.