简体   繁体   中英

Compressed AS2 Body

I am struggling with decompression of a Zlib compressed Mime body of AS2 request coming from BizTalk Server.

The thing is:

The HTTP Body I receive looks as expected. I can read the ASCII encoded Mime Header:

"Content-type: application/pkcs7-mime; smime-type=compressed-data; name=smime.p7m\r\nContent-Transfer-Encoding: binary\r\n\r\n"

Ending with two line breaks, I am expecting the compressed body after. But when I use Ionic.Zlib ZlibStream.UncompressBuffer() to decompress the following bytes it throws an error.

Zlib Header can be identified for example by hex coded bytes "78da". When I start decompressing it from there on, it works fine.

What are the bytes between the two line breaks ending mime header and "78da" starting zlib compressed data?

"3080060b2a864886f70d0109100109a0803080020100300f060b2a864886f70d01091003080500308006092a864886f70d010701a080248004820769"

Next problem, if I read all bytes to the end, the last bytes can not be decompressed. AS far as I Understood the zLib data should end with adler32 checksum, but how can I identify the end or length of the compressed data without trying to decompress. I see some trailing bytes after the sucessfully decompressed data: "1f9b1f1fcbc51f0482000445a59371" What is that?

Thanks for your ideas!

You cannot find the end of the compressed data without decompressing. You don't need to save the result of the decompression, but you at least need to decode all of the compressed data in order to find where it self terminates.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM