mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
fix bug with content type accessors in cases where the content type response header is nil
This commit is contained in:
@@ -220,20 +220,24 @@
|
||||
}
|
||||
|
||||
- (BOOL)isHTML {
|
||||
return [[self contentType] rangeOfString:@"text/html" options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0 ||
|
||||
[self isXHTML];
|
||||
NSString* contentType = [self contentType];
|
||||
return contentType && ([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;
|
||||
NSString* contentType = [self contentType];
|
||||
return contentType && [contentType rangeOfString:@"application/xhtml+xml" options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0;
|
||||
}
|
||||
|
||||
- (BOOL)isXML {
|
||||
return [[self contentType] rangeOfString:@"application/xml" options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0;
|
||||
NSString* contentType = [self contentType];
|
||||
return contentType && [contentType rangeOfString:@"application/xml" options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0;
|
||||
}
|
||||
|
||||
- (BOOL)isJSON {
|
||||
return [[self contentType] rangeOfString:@"application/json" options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0;
|
||||
NSString* contentType = [self contentType];
|
||||
return contentType && [contentType rangeOfString:@"application/json" options:NSCaseInsensitiveSearch|NSAnchoredSearch].length > 0;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user