Closed akirmse closed 2 years ago
Hey @akirmse! Changes described here will land in Android at the same time as in iOS.
Adding interceptor landed in https://github.com/mapbox/mapbox-maps-android/releases/tag/android-v10.0.0-rc.8.
Sample code how to do that will be:
HttpServiceFactory.getInstance().setInterceptor(object : HttpServiceInterceptorInterface() {
override fun onRequest(request: HttpRequest): HttpRequest {
}
override fun onDownload(download: DownloadOptions): DownloadOptions {
}
override fun onResponse(response: HttpResponse): HttpResponse {
}
})
I have a RasterSource that is restricted to only certain User-Agent strings. This is a common anti-scraping measure for tiles stored on e.g. AWS. Not 100% effective, of course, but enough to keep out Web crawlers and most scripts.
I would like to set the User-Agent on HTTP requests from the Mapbox library. I do see a reference to replacing the entire HTTP stack in the Mapbox documentation (https://docs.mapbox.com/android/beta/maps/guides/migrate-to-v10/), but that's massive overkill, and anyway, this is the only reference to
com.mapbox.common.HttpServiceInterface
on the whole Internet, so I'm not sure that it's actually supported and used by clients.There is a similar feature request for the Mapbox iOS SDK where it sounds like support is coming soon: https://github.com/mapbox/mapbox-maps-ios/issues/435
This is easy to do in the Google Maps SDK for both Android and iOS, as the interface is a callback that lets you run arbitrary code to fetch a tile (a much preferable interface that would solve this and many other tile fetching issues).