Dirk
10/18/2022, 5:02 PMDirk
10/18/2022, 5:03 PMoverride fun install(plugin: LoginPlugin, scope: HttpClient) {
<http://console.info|console.info>("Installiere Plugin")
scope.responsePipeline.intercept(HttpResponsePipeline.Receive) { (info, body) ->
val status = context.response.status // Always 0
<http://console.info|console.info>("Ausführung mit Status $status")
if (!(status == HttpStatusCode.Unauthorized || status == HttpStatusCode.TemporaryRedirect || status == HttpStatusCode.Found)) return@intercept
log.debug { "Aufruf des lambdas und Weiterverarbeitung" }
plugin.loginLambda(context.response)
//cancel Response
finish()
}
Dirk
10/18/2022, 5:41 PMAleksei Tirman [JB]
10/19/2022, 8:13 AMCancellationException
:
val client = HttpClient()
client.plugin(HttpSend).intercept { builder ->
val call = execute(builder)
if (call.response.status == HttpStatusCode.Found) {
builder.executionContext.cancel(CancellationException("Status ${call.response.status} is returned from the server"))
}
call
}
try {
client.get("<https://httpbin.org/status/302>")
} catch (e: CancellationException) {
}
Dirk
11/02/2022, 10:50 AM