我正在使用HTTP Post方法并启动同步请求.[NSURLConnection sendSynchronousRequest:..]
对于HTTP POST请求,默认超时发生在75秒,如许多线程中所讨论的.
但是在75秒的超时期间,我们会针对所有相同参数提出的相同请求启动多个Web服务请求.
请告诉我们导致多个请求启动的原因是什么?这是由于HTTP POST一般还是由于同步请求?
@iOS示例代码
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
[request addValue:[NSString stringWithFormat:@"%d", body.length] forHTTPHeaderField: @"Content-Length"];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
NSURLResponse *response;
response = nil;
urlData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if(urlData)
{
NSString *responseString = [[NSString alloc] initWithData:urlData encoding:NSASCIIStringEncoding];
[self parseStringInformation:responseString infoDict:informationDictionary];
//NSLog(@"%@",responseString);
}
Run Code Online (Sandbox Code Playgroud)