Thomas
02/18/2020, 8:45 PMConnectException
. Is the code below correct or is there a better way to do this?
client.install("HttpsToHttp") {
requestPipeline.intercept(HttpRequestPipeline.Before) {
val requestBuilder = this.context
try {
proceedWith(it)
} catch (exception: ConnectException) {
if (requestBuilder.url.protocol == URLProtocol.HTTPS) {
requestBuilder.url.protocol = URLProtocol.HTTP
proceedWith(requestPipeline.execute(requestBuilder, it)) // not sure if this is correct
} else {
throw exception
}
}
}
}
e5l
03/19/2020, 1:34 PMHttpRedirect
feature: https://github.com/ktorio/ktor/blob/b66e3072865de0bff9e6514a5d19cfc404985156/ktor-client/ktor-client-core/common/src/io/ktor/client/features/HttpRedirect.kt#L86Thomas
03/19/2020, 2:20 PMclientConfig.install("HttpsToHttp") {
feature(HttpSend)!!.intercept { origin, context ->
// the code below is not even reached.
try {
execute(context)
} catch (throwable: Throwable) {
TODO()
}
}
}
e5l
03/19/2020, 2:29 PMThomas
03/19/2020, 2:30 PMe5l
03/19/2020, 2:31 PMreceivePipeline
? You can find it in client.receivePipeline
Thomas
03/19/2020, 2:45 PMclientConfig.install("HttpsToHttp") {
receivePipeline.intercept(HttpReceivePipeline.Before) {
TODO()
}
}
The TODO()
is not reached here either, the ssl exception is still thrown like beforee5l
03/19/2020, 2:50 PMreceivePipeline.intercept(HttpReceivePipeline.Before) {
try {
proceedWith(it)
} catch(cause: Throwable) {
}
}
}
Thomas
03/19/2020, 2:59 PMe5l
03/19/2020, 3:00 PMThomas
03/19/2020, 3:02 PMe5l
03/20/2020, 6:43 AMsendPipeline
Before phasesendPipeline.intercept(HttpReceivePipeline.Before) {
try {
proceedWith(it)
} catch(cause: Throwable) {
}
}
}
Thomas
03/20/2020, 4:43 PMe5l
03/20/2020, 7:13 PMThomas
03/21/2020, 6:51 PM