summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2014-04-14 11:17:22 -0400
committerKonstantin Käfer <mail@kkaefer.com>2014-04-14 11:17:22 -0400
commitb4ad5157924bb7af289ce68e4e9f008fd6baa90e (patch)
treee541322cfd9304815c2abdbdee01ec94f40083f6
parente34fc8a303e2bb66c0b76d3d2ebe407c4a92d528 (diff)
downloadqtlocation-mapboxgl-b4ad5157924bb7af289ce68e4e9f008fd6baa90e.tar.gz
don't report intentionally cancelled HTTP requests as error on os x + ios
-rw-r--r--ios/MBXViewController.mm5
-rw-r--r--macosx/main.mm7
2 files changed, 12 insertions, 0 deletions
diff --git a/ios/MBXViewController.mm b/ios/MBXViewController.mm
index f2ed117d46..3e52db752d 100644
--- a/ios/MBXViewController.mm
+++ b/ios/MBXViewController.mm
@@ -479,6 +479,11 @@ namespace llmr
{
dispatch_async(queue, ^(){
[[NSNotificationCenter defaultCenter] postNotificationName:MBXUpdateActivityNotification object:nil];
+ if ([error code] == NSURLErrorCancelled) {
+ // We intentionally cancelled this request. Do nothing.
+ return;
+ }
+
Response res;
if ( ! error && [response isKindOfClass:[NSHTTPURLResponse class]])
diff --git a/macosx/main.mm b/macosx/main.mm
index 705bff8ff5..269d2bc6ed 100644
--- a/macosx/main.mm
+++ b/macosx/main.mm
@@ -48,12 +48,19 @@ Request *request_http(std::string url, std::function<void(Response&)> background
{
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:@(url.c_str())] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
{
+ if ([error code] == NSURLErrorCancelled) {
+ // We intentionally cancelled this request. Do nothing.
+ return;
+ }
+
Response res;
if ( ! error && [response isKindOfClass:[NSHTTPURLResponse class]])
{
res.code = [(NSHTTPURLResponse *)response statusCode];
res.body = { (const char *)[data bytes], [data length] };
+ } else {
+ NSLog(@"http error (%s): %@", url.c_str(), [error localizedDescription]);
}
background_function(res);