I wrote WebSocket in C # and am trying to implement the permessage-deflate extension. It seems that C # DeflateStream cannot decompress the message payload sent from Chrome (version 36.0.1985.143 m) - the only thing I've tried so far. When I try to decompress, I get the message "The length of the block does not match its complement." This is not a problem with RFC 1950, RFC 1951 2 bytes.
I used DeflateStream in C # to compress the same data (the string "Hello"), trying to see the difference in the compressed data. Oddly enough, the chrome compressed data and the C # compressed data are exactly the same except for the first byte! The first byte of the Chrome payload is always 1 less than the first byte, even when changing the sample compression string from "hello" to anything else. I can just add 1 to the first byte and unzip the payload.
I found a Compression Extensions for WebSocket project that discusses this problem but does not solve the problem for C #.
Section 8.2.3.1 uses the Hello example string and shows the correct compressed payload:
0xf2 0x48 0xcd 0xc9 0xc9 0x07 0x00
Then, section 8.2.3.4 discusses the use of the Deflate block with BFINAL set to 1, which produces:
0xf3 0x48 0xcd 0xc9 0xc9 0x07 0x00 0x00
0xf3 data is what C # DeflateStream compresses and decompresses without problems. Does the algorithm seem to have a deflation option that enables BFINAL and that C # does not offer this setting?
I hope someone can be familiar with this problem or know how to get around this problem. I would rather not get involved in a third-party lib if possible.
Thank.
source
share