Merge pull request #1179 from Wszl/master

fixed can't proxy when use username and password
This commit is contained in:
Mariotaku 2019-07-03 16:01:46 +09:00 committed by GitHub
commit ee992c5e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 1 deletions

View File

@ -228,7 +228,16 @@ object HttpClientFactory {
}
val address = InetSocketAddress.createUnresolved(proxyHost, proxyPort)
builder.proxy(Proxy(Proxy.Type.HTTP, address))
builder.proxyAuthenticator { _, response ->
val b = response.request().newBuilder()
if (response.code() == 407) {
if (username != null && password != null) {
val credential = Credentials.basic(username, password)
b.header("Proxy-Authorization", credential)
}
}
b.build()
}
builder.authenticator { _, response ->
val b = response.request().newBuilder()
if (response.code() == 407) {