[android] Updating HttpRequestUrl to separate offline requests from Maps SKU (#15363)
This commit is contained in:
committed by
Chloe Krawczyk
parent
baa7086570
commit
9263cdd856
@@ -10,7 +10,10 @@ public class HttpRequestUrl {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapts a resource request url based on the host and query size.
|
||||
* Adapts a resource request url based on the host, query size, and offline requirement.
|
||||
* Mapbox resources downloaded for offline use are subject to separate Vector Tile and
|
||||
* Raster Tile API pricing and are not included in the Maps SDK’s “unlimited” requests.
|
||||
* See <a href="https://www.mapbox.com/pricing">our pricing page</a> for more information.
|
||||
*
|
||||
* @param host the host used as endpoint
|
||||
* @param resourceUrl the resource to download
|
||||
@@ -25,10 +28,11 @@ public class HttpRequestUrl {
|
||||
} else {
|
||||
resourceUrl = resourceUrl + "&";
|
||||
}
|
||||
resourceUrl = resourceUrl + "sku=" + Mapbox.getSkuToken();
|
||||
|
||||
// Only add SKU token to requests not tagged as "offline" usage.
|
||||
if (offline) {
|
||||
resourceUrl = resourceUrl + "&offline=true";
|
||||
resourceUrl = resourceUrl + "offline=true";
|
||||
} else {
|
||||
resourceUrl = resourceUrl + "sku=" + Mapbox.getSkuToken();
|
||||
}
|
||||
}
|
||||
return resourceUrl;
|
||||
|
||||
@@ -20,14 +20,14 @@ class HttpRequestUrlTest {
|
||||
|
||||
@Test
|
||||
fun testOfflineFlagMapboxCom() {
|
||||
val expected = "http://mapbox.com/path/of/no/return.pbf?sku=foobar&offline=true"
|
||||
val expected = "http://mapbox.com/path/of/no/return.pbf?offline=true"
|
||||
val actual = HttpRequestUrl.buildResourceUrl("mapbox.com", "http://mapbox.com/path/of/no/return.pbf", 0, true)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOfflineFlagMapboxCn() {
|
||||
val expected = "http://mapbox.cn/path/of/no/return.pbf?sku=foobar&offline=true"
|
||||
val expected = "http://mapbox.cn/path/of/no/return.pbf?offline=true"
|
||||
val actual = HttpRequestUrl.buildResourceUrl("mapbox.cn", "http://mapbox.cn/path/of/no/return.pbf", 0, true)
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user