Repository navigation
Identify the app in the tile request User-Agent - #62
Merged
Merged
Conversation
- Add the app package name to the User-Agent of base map and overlay tile requests, as the OSM tile usage policy asks, so a block caused by one app does not affect every app using OpenMapView - Generate only LIBRARY_VERSION and build the User-Agent in UserAgent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tile requests sent the same User-Agent for every app,
OpenMapView/<version> (https://github.com/afarber/OpenMapView). The OSM tile usage policy asks for a User-Agent that identifies the application. If one app overused the tile servers and OSM blocked that string, every app using OpenMapView would lose its tiles. The base map User-Agent also could not be changed, unlike overlays, which can overrideUrlTileProvider.getUserAgent().Now the User-Agent includes the app package name, for both the base map and overlays:
UserAgentobject, filled in fromcontext.packageNameby everyMapController(it is process-wide becauseUrlTileProviderhas noContext)TileDownloaderand the defaultUrlTileProvider.getUserAgent()use it; subclasses that overridegetUserAgent()are unaffectedLIBRARY_VERSIONdocs/PERFORMANCE.mdanddocs/REPLACING_GOOGLE_MAPS.mddescribe the new headerNo public setter is added: the package name already identifies the app, and the Google Maps API has nothing like it. One can be added later if someone needs a custom base map User-Agent.
Tests
UserAgentTest: format with and without a package name, andMapControllersets the package nameTileDownloaderTestandUrlTileProviderTest: base map and overlay requests send the app User-Agent