直接添加一個(gè)AFURLConnectionOperation的category類涵妥,實(shí)現(xiàn)如下代碼即OK。
#import "AFURLConnectionOperation+AuthenticationChallengeUploadFix.h"
@implementation AFURLConnectionOperation (AuthenticationChallengeUploadFix)
- (NSInputStream *)connection:(NSURLConnection __unused *)connection needNewBodyStream:(NSURLRequest *)request {
//蘋果默認(rèn)網(wǎng)絡(luò)請(qǐng)求緩沖區(qū)復(fù)用,當(dāng)緩沖區(qū)溢出后需要重新開辟緩沖區(qū)。否則溢出的數(shù)據(jù)無法上傳服務(wù)器击吱。
if ([request.HTTPBodyStream conformsToProtocol:@protocol(NSCopying)]) {
return [request.HTTPBodyStream copy];
}
return nil;
}
@end
可加群一起交流共同學(xué)習(xí):801216530。