AFNetworking/AFNetworking — pull request #688 by dkasper (2012-12-18 02:27:25+00:00)
Title: Fix timeout on multipart form requests with data that is a multiple of the buffer size

If AFMultipartFormFinalBoundary (34 bytes) doesn't fit into the buffer after finishing the body it isn't finished because the stream is closed. This patches hasAvailableBytes so that read is called again to finish the boundary and then transition to the end state.

To repro try creating data which is just under a multiple of 32768 bytes, since that is the buffer size and sending a multipart form request with something like: https://gist.github.com/4323786

For me this request times out (status code 408) since the final boundary is never completed.