My app will call a webservice to load data. Every time I send the request, the method connection:didReceiveData: is invoked very quick, and I put a NSLog statement inside this method, I can see that the data I receive is just the same as shown in HTT开发者_如何学GoP header field Content-Length. So there should be no more data need to be received. In fact, connection:didReceiveData is not invoked any more. But my connectionDidFinishLoading is invoked exactly 1 minute later every time. Any idea what is going on?
connection:didReceiveData:
is called many times. You must take that data and append it to the data that you got the last time it was called. Only when you receive connectionDidFinishLoading
you know that the transfer is complete and you have all that data.
So just because you receive some data doesn't mean it's done. It's very likely that the server is taking that long to finalize the request or you other issues somewhere in your code, like excessive data processing in your callbacks delaying the execution of the final callback.
精彩评论