How can I check if an URL on a remote server is valid and exists, without
loading the website first?
I tried [myURL checkResourceIsReachableAndReturnError: &error], but that always
returns false, even for a very common URL such as http://www.apple.com/.
That gives me @"NSCocoaErrorDomain" - cod
After some more searching and trying out, I came up with the following:
NSError *error = nil;
NSHTTPURLResponse *response = nil;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:
myURL];
[request setHTTPMethod: @"HEAD"];
NSData
On Aug 5, 2013, at 7:50 AM, Koen van der Drift
wrote:
> How can I check if an URL on a remote server is valid and exists, without
> loading the website first?
That depends on the type of URL. It sounds like you mean HTTP. Basically the
answer is “you can’t” — the only way to check for existe
As Jens explained, your does not have a clean answer.
Doing a HEAD request is "optimal" (huge reduction in network traffic) if you
can accept NO answers from a tiny percentage of sites which will won't return
data to a HEAD request, even though they will return data to a GET.
Thanks for all the suggestions and improvements. I will see what is the best
way for my app to implement these.
- Koen.
On Aug 5, 2013, at 2:41 PM, Jerry Krinock wrote:
> As Jens explained, your does not have a clean answer.
>
> Doing a HEAD request is "optimal" (huge reduction in network tr
On Aug 5, 2013, at 8:41 PM, Jerry Krinock wrote:
> As Jens explained, your does not have a clean answer.
>
> Doing a HEAD request is "optimal" (huge reduction in network traffic) if you
> can accept NO answers from a tiny percentage of sites which will won't
> return data to a HEAD request, ev