2

Working on an iOS project, build it with AFNetworking, has been found that for some requests, AFHTTPRequestOperation doesn't call success or failure blocks.

The specific case is when we tried to download a pdf file, that not exist in the server:

http://www.consejotransparencia.cl/data_casos/ftp_casos/C911-12/C911-12_Decisión_Web.pdf

AFHTTPRequestOperation finally does nothing, and the app get stuck.

The goal is to handle this errors and not get the app stuck.

Anyone knows how to handle this problem?

iDev
  • 23,310
  • 7
  • 60
  • 85
LuisEspinoza
  • 8,508
  • 6
  • 35
  • 57

2 Answers2

2

Maybe the "ó" character it's the problem... try with another filename...

  • YES, this was the problem, the NSURL was not generated properly, so the request didn't work. That's why the success or failure was never called, because the request never work. A simple error. Thanks so much. – LuisEspinoza Dec 14 '12 at 21:28
  • By the way, the encode the URL correctly, check this question: http://stackoverflow.com/questions/4145846/nsurl-with-special-characters – LuisEspinoza Dec 14 '12 at 21:30
0

Try setting a timeout interval to your NSURLRequest?

init your NSURLRequest with initWithURL:cachePolicy:timeoutInterval:

// sample initialization
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:myURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30.0]; // 30 seconds timeout interval.
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

Look at this for handling the timeout.

Community
  • 1
  • 1
Bio
  • 505
  • 4
  • 10
  • Hi @BioCho, tried it, but nothing change. I set a block for the timeout, but nothing happens. I think because the server actually response with 404. – LuisEspinoza Dec 14 '12 at 20:55