Added isHTML and isXHTML MIME type introspection methods

This commit is contained in:
Blake Watters
2010-03-26 15:33:19 -04:00
parent 8bef69adfc
commit ae88704c1d
2 changed files with 19 additions and 0 deletions

View File

@@ -211,6 +211,15 @@
return ([[self allHeaderFields] objectForKey:@"Location"]);
}
- (BOOL)isHTML {
return [[self contentType] rangeOfString:@"text/html" options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0 ||
[self isXHTML];
}
- (BOOL)isXHTML {
return [[self contentType] rangeOfString:@"application/xhtml+xml" options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0;
}
- (BOOL)isXML {
return [[self contentType] rangeOfString:@"application/xml" options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0;
}

View File

@@ -174,6 +174,16 @@
*/
- (NSString*)location;
/**
* True when the server turned an HTML response (MIME type is text/html)
*/
- (BOOL)isHTML;
/**
* True when the server turned an XHTML response (MIME type is application/xhtml+xml)
*/
- (BOOL)isXHTML;
/**
* True when the server turned an XML response (MIME type is application/xml)
*/