Jonathan
12/18/2024, 3:14 PMDaniel Pitts
12/18/2024, 3:26 PMJonathan
12/18/2024, 3:34 PMSeri
12/18/2024, 3:46 PMAuthenticatedHttpClient
and a UnauthenticatedHttpClient
Jonathan
12/18/2024, 4:02 PMDaniel Pitts
12/18/2024, 4:03 PMSam
12/18/2024, 4:41 PMMV
12/18/2024, 7:06 PMopen val client = httpClient.config {
defaultRequest {
if (auth != null) {
headers[HttpHeaders.Authorization] = "Bearer $auth"
}
}
}
Aleksei Tirman [JB]
12/19/2024, 10:03 AMDoes Ktor support conditional headers via a plugin?Yes, Ktor supports sending headers conditionally within a plugin. You can find examples in the documentation.
Jonathan
01/16/2025, 10:25 PMon(Send) { req -> ...}
? Is this an invalid use case? I would like to use the existing Auth plugin but I’d also like to add an additional plugin that will conditional add a bearer token based on a certain condition. Looking at the source code it’s not clear if declaring on(Send)
will work.Aleksei Tirman [JB]
01/17/2025, 7:46 AMon(Send)
in the order they were registered. It's a valid use case. Can you describe the problem in more detail?Daniel Pitts
01/17/2025, 2:47 PMbasic
config block worked, and it was pretty easy to create a custom one.Jonathan
01/17/2025, 2:49 PMDaniel Pitts
01/17/2025, 5:15 PMDaniel Pitts
01/17/2025, 5:17 PMsendWithoutRequest { myBearerTokenIsAvailable(it) } // 'it' is a HttpRequestBuilder if you need anything from it.
Aleksei Tirman [JB]
01/20/2025, 8:31 AM