AlanQuatermain/aqtoolkit — pull request #13 by audungk (2012-01-31 21:04:31+00:00)
Title: Fixed error when reading with AQGZipStream into AQXMLParser using HTTPMessage

I was having an error with AQGZipInputStream used together with AQXMLParser and HTTPMessage, where the stream would throw a Z_BUF_ERROR with no error message, while bytes where still available to read from the buffer. This fix commit solves the issue, but it might be other ways to fix it.

http://zlib,net has further explanation:

>inflate() can also return Z_STREAM_ERROR, which should not be possible here, but could be checked for as >noted above for def(). Z_BUF_ERROR does not need to be checked for here, for the same reasons noted for >def(). Z_STREAM_END will be checked for later.

Also, in some cases when used together with GCD, I would experience issues with close being called twice on the same stream. A check if status equals NSStreamStatusClosed solves this issue