o Don't retry tile downloads after a HTTP 404
Showing
1 changed file
with
7 additions
and
1 deletions
@@ -28,6 +28,8 @@ | @@ -28,6 +28,8 @@ | ||
28 | #import "RMAbstractWebMapSource.h" | 28 | #import "RMAbstractWebMapSource.h" |
29 | #import "RMTileCache.h" | 29 | #import "RMTileCache.h" |
30 | 30 | ||
31 | +#define HTTP_404_NOT_FOUND 404 | ||
32 | + | ||
31 | @implementation RMAbstractWebMapSource | 33 | @implementation RMAbstractWebMapSource |
32 | 34 | ||
33 | @synthesize retryCount, waitSeconds; | 35 | @synthesize retryCount, waitSeconds; |
@@ -143,9 +145,13 @@ | @@ -143,9 +145,13 @@ | ||
143 | { | 145 | { |
144 | for (NSUInteger try = 0; image == nil && try < self.retryCount; ++try) | 146 | for (NSUInteger try = 0; image == nil && try < self.retryCount; ++try) |
145 | { | 147 | { |
148 | + NSHTTPURLResponse *response = nil; | ||
146 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[URLs objectAtIndex:0]]; | 149 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[URLs objectAtIndex:0]]; |
147 | [request setTimeoutInterval:self.waitSeconds]; | 150 | [request setTimeoutInterval:self.waitSeconds]; |
148 | - image = [UIImage imageWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]]; | 151 | + image = [UIImage imageWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil]]; |
152 | + | ||
153 | + if (response.statusCode == HTTP_404_NOT_FOUND) | ||
154 | + break; | ||
149 | } | 155 | } |
150 | } | 156 | } |
151 | 157 |
-
Please register or login to post a comment