NSURLConnection and 404s
NSURLConnection and 404s
- Subject: NSURLConnection and 404s
- From: John Stiles <email@hidden>
- Date: Tue, 26 Oct 2004 15:36:12 -0700
I'm connecting to a web server with NSURLConnection and downloading
data.
It works great; however, I would like to detect 404s ("File Not Found")
or other anomalous conditions.
Right now, as far as I can see, a 404 and successful download are
impossible to differentiate in my code. They both call the following
things in my delegate:
- (void)connection:(NSURLConnection *)connection
didReceiveResponse:(NSURLResponse *)response
OK, I got a response. The NSURLResponse doesn't give me any useful
data and so far everything seems hunky-dory.
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData
*)data
OK, here's some data. Unfortunately, without a lot of hacks, my code
can't tell the difference between data that reads "404 - File not
found!" and regular data. Many web servers also serve up something
fancy, like a picture or even a redirect to a different page, when a
404 error is encountered.
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
OK, we're done. Nothing returned any errors.
Amidst these calls I don't see any place to hook in and grab the HTTP
status value, or in fact any of the HTTP response headers.
What am I missing? Certainly there must be someplace that exposes the
HTTP status code to the outside world.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden