mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template.git
synced 2024-11-17 13:53:52 +00:00
small fix for password setting up in authenticator
This commit is contained in:
parent
22562426e7
commit
c4f214758d
@ -7,10 +7,7 @@ import io.ktor.client.plugins.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.http.*
|
||||
import kotlinx.serialization.Serializable
|
||||
import java.net.Authenticator
|
||||
import java.net.InetSocketAddress
|
||||
import java.net.PasswordAuthentication
|
||||
import java.net.Proxy
|
||||
import java.net.*
|
||||
import java.util.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@ -68,8 +65,12 @@ data class HttpClientConfig(
|
||||
proxyConfig.password ?.toCharArray() ?: error("For Socks proxy you should use both username and password or do not use authentication at all")
|
||||
)
|
||||
Authenticator.setDefault(object : Authenticator() {
|
||||
override fun getPasswordAuthentication(): PasswordAuthentication {
|
||||
return passwordAuthentication
|
||||
override fun getPasswordAuthentication(): PasswordAuthentication? {
|
||||
return if (requestingHost.lowercase() == proxyConfig.hostname.lowercase()) {
|
||||
passwordAuthentication
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user