Skip to content

Instantly share code, notes, and snippets.

@atnan
Created September 9, 2009 06:28
Show Gist options
  • Save atnan/183517 to your computer and use it in GitHub Desktop.
Save atnan/183517 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
int main(void) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSURL* url = [NSURL URLWithString:@"https://twitter.com/"];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"HEAD"];
NSHTTPURLResponse* response;
NSError* error;
[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if (error != nil || [response statusCode] != 200) {
NSLog(@"FAIL! (error = %@, status code = %i)", error, [response statusCode]);
} else {
NSLog(@"SUCCESS!");
}
[pool release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment