Thomas
03/19/2020, 1:26 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
}
}
}
}
Posted in #ktor