mapbox / mapbox/mapbox-maps-android
Library uses wrong User-Agent in HttpServiceInterceptorInterface
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 578
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Android OS version: all
- Devices affected: all
- Maps SDK Version: com.mapbox.maps:android-ndk27:11.25.0
## Observed behavior and steps to reproduce
I need to set a custom user agent on Mapbox tile requests. I have code that looks like this. Note that the user agent that is set via "User-Agent" is ignored; one must use the incorrect "user-agent" as the header name.
```
HttpServiceFactory.setHttpServiceInterceptor(object : HttpServiceInterceptorInterface {
override fun onRequest(
request: HttpRequest,
continuation: HttpServiceInterceptorRequestContinuation
) {
// Set user agent on requests; some servers check this
request.headers["User-Agent"] = NetworkUtils.USER_AGENT_STRING
// TODO: Mapbox incorrectly uses the header in lowercase. Remove when fixed in Mapbox.
request.headers["user-agent"] = NetworkUtils.USER_AGENT_STRING
continuation.run(HttpRequestOrResponse(request))
}
```
This worked in previous versions of Mapbox but broke sometime in the last year or two.
## Expected behavior
Here is the RFC that documents that the correct name of the header is "User-Agent" (capitalized).
https://httpwg.org/specs/rfc9110.html#field.user-agent
The iOS Mapbox library uses the correct "User-Agent".
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing HttpServiceInterceptorInterface and HttpServiceFactory into the Android HTTP request implementation, then reproduce the behavior with the interceptor shown in the issue. Done means custom User-Agent values are honored using the documented header spelling, with focused coverage for intercepted tile requests if the existing test structure supports it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile-dev, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100