Slow download using NSURLConnection
I am perform a request (SOAP webservice) and seing extremely slow response times (see log below).
This problem is happening both on devices and also in the simulator.
When I perform the same request using cURL or SoapUI however the call completes within a second. What could be causing this?Code
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapRequest length]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[soapRequest dataUsingEncoding:NSUTF8StringEncoding]];
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
Simulator Logs
00:58:31.727 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[1440]
00:58:32.858 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[1440]
00:58:33.979 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[5760]
00:58:35.106 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[8640]
00:58:36.130 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[1440]
00:58:38.287 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[1440]
00:58:40.430 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size开发者_StackOverflow中文版[1440]
00:58:41.762 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[1440]
00:58:42.273 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[1440]
00:58:42.274 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[1440]
00:58:45.243 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[1440]
00:58:46.532 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[1440]
00:58:48.008 [WSClient connection:didReceiveData:] [Line 109] |NETWORK| Received data. Size[428]
00:58:48.010 [WSClient connectionDidFinishLoading:] [Line 121] |NETWORK| Done
I cannot answer your immediate question. Maybe it has something to do with your delegate handlers? Might help to post those too.
In any case, I really wanted to bring ASIHTTPRequest to your attention. It's a widely used and popular alternative and might make your life easier.
精彩评论