mapbox / mapbox/mapbox-maps-android

Library uses wrong User-Agent in HttpServiceInterceptorInterface

Open
#2,724 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :beetle:
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.