流量拦截在post上传图片时出现的问题
Created by: Wbqqqq
ios流量拦截: 假设post上传图片时,
if ([request.HTTPMethod isEqualToString:@"POST"]) { if (!request.HTTPBody) { uint8_t d[1024] = {0}; NSInputStream *stream = request.HTTPBodyStream; NSMutableData *data = [[NSMutableData alloc] init]; [stream open]; while ([stream hasBytesAvailable]) { NSInteger len = [stream read:d maxLength:1024]; if (len > 0 && stream.streamError == nil) { [data appendBytes:(void *)d length:len]; } } httpBody = [data copy]; [stream close]; } }
读流的时候会一直,会在while死循环,导致超时失败。 iOS13.3 、iphone8p