• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Not getting all the data over the cell network
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Not getting all the data over the cell network


  • Subject: Not getting all the data over the cell network
  • From: Stevo Brock <email@hidden>
  • Date: Wed, 08 Aug 2012 12:19:14 -0700

We are seeing quite an odd situation in our app.  When running the app on an iPhone 4 with iOS 4.3.5 (other combinations also exhibit this behavior but I don't have the exact details at the moment) and forcing data traffic to go over the cell network, our URL data loading calls are often not returning the entire set of bytes.  Here is the code:

Option 1: Basic
	NSData* data = [NSData dataWithContentsOfURL:mURL];

Option 2: Check for return error
	NSError* error = nil;
	NSData* data = [[[NSData alloc] initWithContentsOfURL:mURL 0 error:&error] autorelease];

Option 3: Use NSURLConnection
	NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:mURL];
	NSHTTPURLResponse* response = nil;
	NSError* error = nil;
	NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
	NSInteger responseStatus = [response statusCode];

	NSLog(@"response code: %d", responseStatus);
	NSLog(@"response headers: %@", [response allHeaderFields]);

Returns the following info every time:

2012-08-08 11:54:20.815 App[994:8207] response code: 200
2012-08-08 11:54:20.817 App[994:8207] response headers: {
    "Accept-Ranges" = bytes;
    "Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
    "Content-Encoding" = gzip;
    "Content-Length" = 87187;
    "Content-Type" = "application/pdf";
    Date = "Wed, 08 Aug 2012 18:54:20 GMT";
    Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
    P3p = "CP=\"NOI DSP COR CUR IVD OTPi OUR STP INT\", policyref=\"/w3c/p3p.xml\"";
    Pragma = "no-cache";
    Server = "Apache/2.2.3 (CentOS)";
    "Set-Cookie" = "fromov=deleted; expires=Tue, 09-Aug-2011 18:54:19 GMT; path=/";
    Vary = "Accept-Encoding";
}

Option 4: Try on main thread
	NSMutableData* storageData = [NSMutableData data];
	[self performSelectorOnMainThread:@selector(loadURL:) withObject: storageData waitUntilDone:YES];

- (void) loadURL:(NSMutableData*) storageData
{
	NSData* data = [NSData dataWithContentsOfURL:mURL];
	[storageData appendData:data];
}

What we see is that occasionally (25% of the time?) the app loads all 87187 bytes, but the rest of the time, the app loads less data and no error or any other condition is ever returned.

Does anyone have any idea what could be going wrong and perhaps what is the recommended approach to consistently and correctly loading data over the cell network?


-Stevo Brock
 Sunset Magicwerks, LLC
 www.sunsetmagicwerks.com
 818-609-0258

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Not getting all the data over the cell network
      • From: Jens Alfke <email@hidden>
  • Prev by Date: PocketSVG
  • Next by Date: Navigating in a NSTableView with tab key
  • Previous by thread: PocketSVG
  • Next by thread: Re: Not getting all the data over the cell network
  • Index(es):
    • Date
    • Thread