ASIHTTPRequest video download failed sometimes and sometimes not? - ios5

In my project i need to download nearly 50 videos from cloud, i download it using ASIHTTPRequest in Asynchronous way by handling responses using success and failure delegate methods.
When video download is success the corresponding success delegate method is called and i got status code 200, if partial download i got status code 206 in same delegate method and if file not found i got status code 404 on success delegate method.
If request itself failed it hit the corresponding failure delegate method, some times it return status code 200 in failure delegate method. But status 200 for success only.
Another thing i need to make video download complete without any failure(How can i handle this).If any one knows help me out.
Thanks

Related

UseProtocolCachePolicy hide 304 status code

I am setting cachePolicy on url request.
First call to an url (GET) return status code in 200.
Second call to the same url return 200.
If use a rest client i obtain for the first call 200, and for the second, with properly header ( If-None-Match) 304
Reading online i understand that iOS serialize first request with status code 200 and retrieve it for the second call.
There is a way to obtain 304 instead of 200 in UrlCache or understand if it the data came from cache and not from network.
From http://jonathanblog2000.blogspot.com/2017/07/ios-uiwebview-nsurlsession-cache.html :
If you want to test and verify the cache works properly in your app, you have to log the device http traffic, as the delegate of NSURLSession will never see the 304 status code returned from server, it will be automatically replaced by the status code in the cached response.
This is a good thing. This means your app can just pretend you got a successful response, and not worry about how the response was obtained or what sort of optimizations was happening. You just deal with the response the same way regardless of whether it was pulled from the cache or not.

NSURLConnection delegate methods not giving the response immediately

Hi in my application I am using NSURLConnection delegate metods to get a response from the server.Here what is happening is when ever I send a request to the server for the first time I am getting response immediately.After that first request if I send same request to the server again immediately I am getting the response as null. But if i leave the ipad aside after sometime I am getting the response can you please let me know is there any time limit needed between the requests while sending to the server using NSURLConnection delegate methods.Please help me to resolve this issue.
Thanks in advance.

AFNetworking and Network Errors

I am using the AFNetworking framework to make several JSON web request.
During development if I fail to provide a required parameters or the Service developers have broken something :-) i receive a 500 error
The Error block of AFJSONRequestOperation is correctly catching it. However i cannot see the page body because AfNetworking is cancelling the request as soon as the error code in the head is received.
Is there some work around. I would like to spit out the response body to the log.
Use the responseData or responseString property from the operation that's passed into the failure block.
You'll need to add the http Code 500 to the acceptable status codes and filter it on the success callback. There you will have a responseObject.

Handling 404 error problems in the WebView Delegate in iPhone sdk

I am working with WebView based application, in that I had a problem with http 404 errors when I tried to load an url. I just want to show an alert when this happens. Can you guys please suggest me that how to trigger it and is there are any delegate methods fired when this happens?. Please suggest.
Thanks in adv,
S.
You can not check the status code for UIWebView requests. I rarely use webviews to do requests and when I do I don't care what the status codes are. I usually use NSURLConnection or ASIHTTPRequest to do requests. If you have to know the status of the http request, then do it using an NSURLRequest object and set the delegate to receive the response status code.

NSMutableURLRequest: didReceiveData not called at the first time

I've dug through a lot of topics regarding didReceiveData: method not being called - the solution is to set appropriate cachePolicy and implement willCacheResponse delegate method.
So I did, now I get didReceiveData message each time anything comes from the server.
Unfortunately I don't get didReceiveData the very first time the server responds.
In other words, the first time I get "didReceiveData" message there are 2 response objects in the "data" parameter. Every response from the server following that moment is OK.
Any help?
Just needed a clarification; Are you using any threading in your application?
If Yes, then the thread which creates the connection should receive the response from the server. The other threads will not identify the response which is returned for some other thread.