zwopple / PocketSocket

Objective-C websocket library for building things that work in realtime on iOS and OS X.
Other
414 stars 129 forks source link

inflateInit2(&_stream, -MAX_WBITS) #42

Closed seviu closed 8 years ago

seviu commented 8 years ago

On some instances headers are missing and inflateInit2 fails.

This fix can also be applied on the development branch:

http://stackoverflow.com/questions/18700656/zlib-inflate-failing-with-3-z-data-error

Inflate() was failing because it was looking for GZip headers which were not present. If you initialize the stream with:

ret = inflateInit2(&strm, -MAX_WBITS); Passing a negative window bits value prevents inflate from checking for gzip or zlib headers and unzipping works as expected.

robertjpayne commented 8 years ago

@seviu hrm, I'll hvae to run the autobahn tests against this, the reason the window bits is used is because of how the permessage-deflate protocol works

robertjpayne commented 8 years ago

@seviu I'm not actually sure this is 100% the problem, There's currently a lot of problems with the permessage-deflate extension (newer Autobahn tests have uncovered flawed implementation). At this point I don't really have time or a desire to fix it that much so I may just disable the permessage-deflate extension all together…

robertjpayne commented 8 years ago

@seviu just heads up two things are landing in develop that should resolve this issue for you:

robertjpayne commented 8 years ago

Closing this PR as it's not actually the fix, the issue with PocketSocket was a invalid permessage-deflate implementation that could cause bugs for fragmented websocket frames. This is going to land in develop in the next few hours.

robertjpayne commented 8 years ago

@seviu this is now live on CocoaPods as v 1.0.0