Issue: Timeout when buffer ends during ending boundry
This commit is contained in:
parent
247863cfc2
commit
c92f306c6d
1 changed files with 28 additions and 25 deletions
|
|
@ -657,8 +657,8 @@ static void AFNetworkReachabilityReleaseCallback(const void *info) {}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.stringEncoding = (NSStringEncoding)[aDecoder decodeIntegerForKey:@"stringEncoding"];
|
self.stringEncoding = [aDecoder decodeIntegerForKey:@"stringEncoding"];
|
||||||
self.parameterEncoding = (AFHTTPClientParameterEncoding)[aDecoder decodeIntegerForKey:@"parameterEncoding"];
|
self.parameterEncoding = [aDecoder decodeIntegerForKey:@"parameterEncoding"];
|
||||||
self.registeredHTTPOperationClassNames = [aDecoder decodeObjectForKey:@"registeredHTTPOperationClassNames"];
|
self.registeredHTTPOperationClassNames = [aDecoder decodeObjectForKey:@"registeredHTTPOperationClassNames"];
|
||||||
self.defaultHeaders = [aDecoder decodeObjectForKey:@"defaultHeaders"];
|
self.defaultHeaders = [aDecoder decodeObjectForKey:@"defaultHeaders"];
|
||||||
|
|
||||||
|
|
@ -940,7 +940,6 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
|
||||||
if ([self streamStatus] == NSStreamStatusClosed) {
|
if ([self streamStatus] == NSStreamStatusClosed) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSInteger bytesRead = 0;
|
NSInteger bytesRead = 0;
|
||||||
|
|
||||||
while ((NSUInteger)bytesRead < MIN(length, self.numberOfBytesInPacket)) {
|
while ((NSUInteger)bytesRead < MIN(length, self.numberOfBytesInPacket)) {
|
||||||
|
|
@ -955,7 +954,6 @@ NSTimeInterval const kAFUploadStream3GSuggestedDelay = 0.2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1034,6 +1032,7 @@ typedef enum {
|
||||||
AFHeaderPhase = 2,
|
AFHeaderPhase = 2,
|
||||||
AFBodyPhase = 3,
|
AFBodyPhase = 3,
|
||||||
AFFinalBoundaryPhase = 4,
|
AFFinalBoundaryPhase = 4,
|
||||||
|
AFEndPhase = 5,
|
||||||
} AFHTTPBodyPartReadPhase;
|
} AFHTTPBodyPartReadPhase;
|
||||||
|
|
||||||
@interface AFHTTPBodyPart () {
|
@interface AFHTTPBodyPart () {
|
||||||
|
|
@ -1098,6 +1097,9 @@ typedef enum {
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)hasBytesAvailable {
|
- (BOOL)hasBytesAvailable {
|
||||||
|
if (_phase == AFFinalBoundaryPhase) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
switch (self.inputStream.streamStatus) {
|
switch (self.inputStream.streamStatus) {
|
||||||
case NSStreamStatusNotOpen:
|
case NSStreamStatusNotOpen:
|
||||||
case NSStreamStatusOpening:
|
case NSStreamStatusOpening:
|
||||||
|
|
@ -1114,7 +1116,6 @@ typedef enum {
|
||||||
|
|
||||||
- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length {
|
- (NSInteger)read:(uint8_t *)buffer maxLength:(NSUInteger)length {
|
||||||
NSInteger bytesRead = 0;
|
NSInteger bytesRead = 0;
|
||||||
|
|
||||||
if (_phase == AFEncapsulationBoundaryPhase) {
|
if (_phase == AFEncapsulationBoundaryPhase) {
|
||||||
NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding];
|
NSData *encapsulationBoundaryData = [([self hasInitialBoundary] ? AFMultipartFormInitialBoundary() : AFMultipartFormEncapsulationBoundary()) dataUsingEncoding:self.stringEncoding];
|
||||||
bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)];
|
bytesRead += [self readData:encapsulationBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)];
|
||||||
|
|
@ -1137,9 +1138,9 @@ typedef enum {
|
||||||
|
|
||||||
if (_phase == AFFinalBoundaryPhase) {
|
if (_phase == AFFinalBoundaryPhase) {
|
||||||
NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding] : [NSData data]);
|
NSData *closingBoundaryData = ([self hasFinalBoundary] ? [AFMultipartFormFinalBoundary() dataUsingEncoding:self.stringEncoding] : [NSData data]);
|
||||||
|
|
||||||
bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)];
|
bytesRead += [self readData:closingBoundaryData intoBuffer:&buffer[bytesRead] maxLength:(length - bytesRead)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1178,11 +1179,13 @@ typedef enum {
|
||||||
[self.inputStream close];
|
[self.inputStream close];
|
||||||
_phase = AFFinalBoundaryPhase;
|
_phase = AFFinalBoundaryPhase;
|
||||||
break;
|
break;
|
||||||
|
case AFFinalBoundaryPhase:
|
||||||
|
_phase = AFEndPhase;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
_phase = AFEncapsulationBoundaryPhase;
|
_phase = AFEncapsulationBoundaryPhase;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_phaseReadOffset = 0;
|
_phaseReadOffset = 0;
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue