add unauthorized convenience method on rkresponse

This commit is contained in:
Jeff Arena
2010-12-29 17:04:37 -08:00
parent a61728aa28
commit df62bce0dd
2 changed files with 16 additions and 7 deletions

View File

@@ -133,6 +133,11 @@
*/
- (BOOL)isCreated;
/**
* Indicates an HTTP response code of 401
*/
- (BOOL)isUnauthorized;
/**
* Indicates an HTTP response code of 403
*/

View File

@@ -20,7 +20,7 @@
_failureError = nil;
_loading = NO;
}
return self;
}
@@ -30,7 +30,7 @@
// request ownership
_request = request;
}
return self;
}
@@ -44,7 +44,7 @@
_body = [body retain];
_loading = NO;
}
return self;
}
@@ -76,8 +76,8 @@
[[_request delegate] requestDidStartLoad:_request];
}
}
[_body appendData:data];
[_body appendData:data];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response {
@@ -93,7 +93,7 @@
[_request didFailLoadWithError:_failureError];
}
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite {
if ([[_request delegate] respondsToSelector:@selector(request:didSendBodyData:totalBytesWritten:totalBytesExpectedToWrite:)]) {
[[_request delegate] request:_request didSendBodyData:bytesWritten totalBytesWritten:totalBytesWritten totalBytesExpectedToWrite:totalBytesExpectedToWrite];
}
@@ -115,7 +115,7 @@
if ([self isFailure]) {
return [_failureError localizedDescription];
} else {
return nil;
return nil;
}
}
@@ -175,6 +175,10 @@
return ([self statusCode] == 201);
}
- (BOOL)isUnauthorized {
return ([self statusCode] == 401);
}
- (BOOL)isForbidden {
return ([self statusCode] == 403);
}