Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:AFNetworking/AFNetworking
Browse files Browse the repository at this point in the history
  • Loading branch information
mattt committed Nov 17, 2014
2 parents da67eae + 85f2bae commit 169ef04
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions AFNetworking/AFURLResponseSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ - (BOOL)validateResponse:(NSHTTPURLResponse *)response

if (response && [response isKindOfClass:[NSHTTPURLResponse class]]) {
if (self.acceptableContentTypes && ![self.acceptableContentTypes containsObject:[response MIMEType]]) {
if ([data length] > 0) {
if ([data length] > 0 && [response URL]) {
NSMutableDictionary *mutableUserInfo = [@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: unacceptable content-type: %@", @"AFNetworking", nil), [response MIMEType]],
NSURLErrorFailingURLErrorKey:[response URL],
Expand All @@ -129,7 +129,7 @@ - (BOOL)validateResponse:(NSHTTPURLResponse *)response
responseIsValid = NO;
}

if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode]) {
if (self.acceptableStatusCodes && ![self.acceptableStatusCodes containsIndex:(NSUInteger)response.statusCode] && [response URL]) {
NSMutableDictionary *mutableUserInfo = [@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedStringFromTable(@"Request failed: %@ (%ld)", @"AFNetworking", nil), [NSHTTPURLResponse localizedStringForStatusCode:response.statusCode], (long)response.statusCode],
NSURLErrorFailingURLErrorKey:[response URL],
Expand Down
10 changes: 4 additions & 6 deletions UIKit+AFNetworking/UIRefreshControl+AFNetworking.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task {
[notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];

if (task) {
if (task.state != NSURLSessionTaskStateCompleted) {
if (task.state == NSURLSessionTaskStateRunning) {
[self beginRefreshing];
} else {
[self endRefreshing];
}
if (task.state == NSURLSessionTaskStateRunning) {
[self beginRefreshing];

[notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task];
[notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task];
[notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task];
} else {
[self endRefreshing];
}
}
}
Expand Down

0 comments on commit 169ef04

Please sign in to comment.