Stephan Schröder
10/09/2025, 12:53 PMAccept: */* header to any request I send (that didn't contain an Accept header to start with). According to this old answer to this similar problem I'd have to disable all DefaultTransfermers. But that answer is from 2022. Is there a better solution with Ktor 3?
Update: I found a workaround! With an OkHttp engine, i can add an interceptor to modify headers after ktor adds it's bonus headers.
HttpClient(OkHttp) {
install(HttpTimeout) {
requestTimeoutMillis = timeout.inWholeMilliseconds
}
engine {
addInterceptor { chain ->
val original = chain.request()
val filtered = original.newBuilder().apply {
removeHeader(HttpHeaders.Accept)
}.build()
chain.proceed(filtered)
}
}
}
If you have a better solution, I'm all ears.Aleksei Tirman [JB]
10/10/2025, 6:38 AMStephan Schröder
10/10/2025, 3:48 PM