AFNetworking/AFNetworking — pull request #636 by tomohisa (2012-11-09 22:30:57+00:00)
Title: Timeout when buffer filled with ending boundary

I have fixed this for my project. I would like to contribute.

AFHTTPBodyPart returns hasBytesAvailable NO after body finished.
but buffer could fill when I am sending ending boundary.

So basically I changed

- (BOOL)hasBytesAvailable {
if (_phase == AFFinalBoundaryPhase) {
return YES;
}
switch (self.inputStream.streamStatus) {
case NSStreamStatusNotOpen:
case NSStreamStatusOpening:
case NSStreamStatusOpen:
case NSStreamStatusReading:
case NSStreamStatusWriting:
return YES;
case NSStreamStatusAtEnd:
case NSStreamStatusClosed:
case NSStreamStatusError:
return NO;
}
}

So when it running final boundary, you shouldn't return NO. For safety, I have put AFEndPhase and when final boundary finishes, change Phase to Ending Phase. Hope this helps to improve AFNetworking. We've loved to use Good library like AFNetworking and would love to help improve.