diff options
author | M.Stephen <truestyle2005@163.com> | 2019-12-13 17:30:15 +0800 |
---|---|---|
committer | M.Stephen <truestyle2005@163.com> | 2019-12-13 17:30:15 +0800 |
commit | 84af0971afb648e0c9567d43b00a83c28fa4ef5b (patch) | |
tree | d3a32fd9abc45ab81b4bb905c4f3ec6575a19d45 | |
parent | 3afd98bf013d9b1e00002966383dc9663440543e (diff) | |
download | qtlocation-mapboxgl-84af0971afb648e0c9567d43b00a83c28fa4ef5b.tar.gz |
re-add account type into `http_file_source`
-rw-r--r-- | platform/darwin/include/mbgl/interface/native_apple_interface.h | 5 | ||||
-rw-r--r-- | platform/darwin/src/http_file_source.mm | 9 |
2 files changed, 10 insertions, 4 deletions
diff --git a/platform/darwin/include/mbgl/interface/native_apple_interface.h b/platform/darwin/include/mbgl/interface/native_apple_interface.h index c3e6aaa985..59e5d5431f 100644 --- a/platform/darwin/include/mbgl/interface/native_apple_interface.h +++ b/platform/darwin/include/mbgl/interface/native_apple_interface.h @@ -36,7 +36,10 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSURLSessionConfiguration *sessionConfiguration; -//For testing +/* + For testing. Since we get a `nil` return when SDK is modualar, we use this for testing network. + Same as `[MGLNetworkConfiguration defaultSessionConfiguration]` in `MGLNetworkConfiguration.m`. + */ @property (nonatomic, readonly) NSURLSessionConfiguration *testSessionConfiguration; - (void)startDownloadEvent:(NSString *)event type:(NSString *)type; diff --git a/platform/darwin/src/http_file_source.mm b/platform/darwin/src/http_file_source.mm index 252f815f69..a5f0f8dbb7 100644 --- a/platform/darwin/src/http_file_source.mm +++ b/platform/darwin/src/http_file_source.mm @@ -95,6 +95,7 @@ public: NSURLSession* session = nil; NSString* userAgent = nil; + NSInteger accountType = 0; private: NSString* getUserAgent() const; @@ -197,12 +198,12 @@ BOOL isValidMapboxEndpoint(NSURL *url) { } MGL_APPLE_EXPORT -NSURL *resourceURLWithAccountType(const Resource& resource) { +NSURL *resourceURLWithAccountType(const Resource& resource, NSInteger accountType) { NSURL *url = [NSURL URLWithString:@(resource.url.c_str())]; #if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR - if (isValidMapboxEndpoint(url)) { + if (accountType == 0 && isValidMapboxEndpoint(url)) { NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO]; NSMutableArray *queryItems = [NSMutableArray array]; @@ -220,6 +221,8 @@ NSURL *resourceURLWithAccountType(const Resource& resource) { components.queryItems = queryItems; url = components.URL; } +#else + (void)accountType; #endif return url; } @@ -229,7 +232,7 @@ std::unique_ptr<AsyncRequest> HTTPFileSource::request(const Resource& resource, auto shared = request->shared; // Explicit copy so that it also gets copied into the completion handler block below. @autoreleasepool { - NSURL *url = resourceURLWithAccountType(resource); + NSURL *url = resourceURLWithAccountType(resource, impl->accountType); [MGLNativeNetworkManager.sharedManager debugLog:@"Requesting URI: %@", url.relativePath]; NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; |