Adding check for responseData having non-zero length for response object methods in AFHTTPRequestOperation subclasses
This commit is contained in:
parent
eabde28fd6
commit
b782991065
4 changed files with 6 additions and 6 deletions
|
|
@ -156,7 +156,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
|||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED
|
||||
- (UIImage *)responseImage {
|
||||
if (!_responseImage && [self isFinished]) {
|
||||
if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) {
|
||||
UIImage *image = [UIImage imageWithData:self.responseData];
|
||||
|
||||
self.responseImage = [UIImage imageWithCGImage:[image CGImage] scale:self.imageScale orientation:image.imageOrientation];
|
||||
|
|
@ -178,7 +178,7 @@ static dispatch_queue_t image_request_operation_processing_queue() {
|
|||
}
|
||||
#elif __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
- (NSImage *)responseImage {
|
||||
if (!_responseImage && [self isFinished]) {
|
||||
if (!_responseImage && [self.responseData length] > 0 && [self isFinished]) {
|
||||
// Ensure that the image is set to it's correct pixel width and height
|
||||
NSBitmapImageRep *bitimage = [[NSBitmapImageRep alloc] initWithData:self.responseData];
|
||||
self.responseImage = [[[NSImage alloc] initWithSize:NSMakeSize([bitimage pixelsWide], [bitimage pixelsHigh])] autorelease];
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
|
|||
}
|
||||
|
||||
- (id)responseJSON {
|
||||
if (!_responseJSON && [self isFinished]) {
|
||||
if (!_responseJSON && [self.responseData length] > 0 && [self isFinished]) {
|
||||
NSError *error = nil;
|
||||
|
||||
if ([self.responseData length] == 0) {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ static dispatch_queue_t property_list_request_operation_processing_queue() {
|
|||
}
|
||||
|
||||
- (id)responsePropertyList {
|
||||
if (!_responsePropertyList && [self isFinished]) {
|
||||
if (!_responsePropertyList && [self.responseData length] > 0 && [self isFinished]) {
|
||||
NSPropertyListFormat format;
|
||||
NSError *error = nil;
|
||||
self.responsePropertyList = [NSPropertyListSerialization propertyListWithData:self.responseData options:self.propertyListReadOptions format:&format error:&error];
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
|
|||
}
|
||||
|
||||
- (NSXMLParser *)responseXMLParser {
|
||||
if (!_responseXMLParser && [self isFinished]) {
|
||||
if (!_responseXMLParser && [self.responseData length] > 0 && [self isFinished]) {
|
||||
self.responseXMLParser = [[[NSXMLParser alloc] initWithData:self.responseData] autorelease];
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ static dispatch_queue_t xml_request_operation_processing_queue() {
|
|||
|
||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED
|
||||
- (NSXMLDocument *)responseXMLDocument {
|
||||
if (!_responseXMLDocument && [self isFinished]) {
|
||||
if (!_responseXMLDocument && [self.responseData length] > 0 && [self isFinished]) {
|
||||
NSError *error = nil;
|
||||
self.responseXMLDocument = [[[NSXMLDocument alloc] initWithData:self.responseData options:0 error:&error] autorelease];
|
||||
self.error = error;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue