- (void)checkMIMEType:(NSURL *)url
{
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
[req setHTTPMethod:@"HEAD"];
[[NSURLConnection connectionWithRequest:req delegate:self] start];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
NSLog(@"didReceiveResponse: %@, URL: %@", [response MIMEType], connection.currentRequest.URL);
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSLog(@"didReceiveData: %lu", [data length]);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSLog(@"didReceiveLoading");
}
以上述的例子中,當 [req setHTTPMethod:@"HEAD"]; 時,不會跑進 connection: didReceiveData: 裡。
沒有留言:
張貼留言