net: send the subtracks user agent on every request

Only SubsonicClient tagged requests with 'subtracks/android'; playback (Media3 OkHttpDataSource), downloads (DownloadManager) and artwork (Coil/OkHttpArtworkFetcher) fell back to the OkHttp or platform default. Add a single UserAgent with the app version, apply it to the shared OkHttp client, the streaming data source factory and the DownloadManager request, and drop SubsonicClient's now-redundant header.
This commit is contained in:
austinried
2026-10-09 06:33:22 +00:00
parent ce9e3e89a7
commit bcd7bbf23a
6 changed files with 49 additions and 4 deletions
@@ -0,0 +1,24 @@
package com.subtracks
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import org.junit.Assert.assertEquals
import org.junit.Test
class UserAgentTest {
@Test
fun addsTheSubtracksUserAgent() {
val server = MockWebServer()
server.enqueue(MockResponse())
server.start()
val client = OkHttpClient.Builder().addInterceptor(UserAgent.interceptor()).build()
client.newCall(Request.Builder().url(server.url("/")).build()).execute().close()
val header = server.takeRequest().getHeader("User-Agent")
server.shutdown()
assertEquals(UserAgent.value, header)
}
}