Merge pull request #15 from adamjernst/master
Only check HTTP status code if network error did not occur
This commit is contained in:
commit
a129302be5
1 changed files with 10 additions and 8 deletions
|
|
@ -64,6 +64,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
|
||||||
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
|
failure:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
|
||||||
{
|
{
|
||||||
return [self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
|
return [self operationWithRequest:urlRequest completion:^(NSURLRequest *request, NSHTTPURLResponse *response, NSData *data, NSError *error) {
|
||||||
|
if (!error) {
|
||||||
BOOL statusCodeAcceptable = [acceptableStatusCodes containsIndex:[response statusCode]];
|
BOOL statusCodeAcceptable = [acceptableStatusCodes containsIndex:[response statusCode]];
|
||||||
BOOL contentTypeAcceptable = [acceptableContentTypes containsObject:[response MIMEType]];
|
BOOL contentTypeAcceptable = [acceptableContentTypes containsObject:[response MIMEType]];
|
||||||
if (!statusCodeAcceptable || !contentTypeAcceptable) {
|
if (!statusCodeAcceptable || !contentTypeAcceptable) {
|
||||||
|
|
@ -73,6 +74,7 @@ static dispatch_queue_t json_request_operation_processing_queue() {
|
||||||
|
|
||||||
error = [[[NSError alloc] initWithDomain:NSURLErrorDomain code:[response statusCode] userInfo:userInfo] autorelease];
|
error = [[[NSError alloc] initWithDomain:NSURLErrorDomain code:[response statusCode] userInfo:userInfo] autorelease];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
if (failure) {
|
if (failure) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue