/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 */
package com.runicgateway.app.core.net

import okhttp3.Interceptor
import okhttp3.Response

/**
 * Sets a stable, identifiable User-Agent on every request. The website mounts a
 * bot/scanner guard ahead of routing (PLAN.md §8); a native client must present
 * a sane UA so it is not caught by the scanner heuristics that reject blank or
 * default agents. Constructed with the app's UA string in the network module.
 */
class UserAgentInterceptor(
    private val userAgent: String,
) : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request().newBuilder()
            .header("User-Agent", userAgent)
            .build()
        return chain.proceed(request)
    }
}
