From 48e13928d0386779a332392d462e98f8ad4009cf Mon Sep 17 00:00:00 2001 From: ettore Date: Fri, 27 Jan 2012 14:52:14 -0800 Subject: [PATCH] do not attempt to start connection when URL is nil --- src/Three20Network/Sources/TTRequestLoader.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Three20Network/Sources/TTRequestLoader.m b/src/Three20Network/Sources/TTRequestLoader.m index 37efcd04a1..173abef4c0 100644 --- a/src/Three20Network/Sources/TTRequestLoader.m +++ b/src/Three20Network/Sources/TTRequestLoader.m @@ -124,18 +124,19 @@ - (void)connectToURL:(NSURL*)URL { [self performSelector:@selector(deliverDataResponse:) withObject:URL afterDelay:0.1]; return; } - TTNetworkRequestStarted(); - TTURLRequest* request = _requests.count >= 1 ? [_requests objectAtIndex:0] : nil; // there are situations where urlPath is somehow nil (therefore crashing in // createNSURLRequest:URL:, even if we checked for non-blank values before // adding the request to the queue. - if (!request.urlPath.length) + if (!request.urlPath.length) { [self cancel:request]; + if (URL == nil) + return; // no url whatsoever, nothing to do here + } + TTNetworkRequestStarted(); NSURLRequest* URLRequest = [_queue createNSURLRequest:request URL:URL]; - _connection = [[NSURLConnection alloc] initWithRequest:URLRequest delegate:self]; }