snej / MYNetwork

Mooseyard Networking library: Cocoa utilities, including a generic TCP server/client, plus the reference implementation of the message-oriented BLIP protocol. (This is a mirror of the Mercurial repository at https://bitbucket.org/snej/mynetwork)
27 stars 9 forks source link

compression flag not properly queried #17

Open levigroker opened 6 years ago

levigroker commented 6 years ago

In BLIPMessage.m _receivedFrameWithFlags: body: line 365:

if( self.compressed && encodedLength>0 ) {

self.compressed refers to _flags which has not been updated with the flags passed into the method and therefore self.compressed will return NO even if the given flags suggest the body is compressed. This causes the body data to not be decompressed and confuses consumers of the message.

I'm not sure what the proper fix is since I don't quite understand the relationship between _flags and flags, but the method seems to use them in an inconsistent way throughout. It would seem _flags needs to be properly updated by the passed in flags parameter...

As a workaround (which reflects from previous revisions), one can replace line 365 with:

if( flags & kBLIP_Compressed && encodedLength>0 ) {