1
0
mirror of https://github.com/square/okhttp.git synced 2025-08-10 11:03:02 +03:00

Adopt idiomatic Kotlin in Challenge

This commit is contained in:
Jesse Wilson
2019-05-13 20:55:47 -04:00
parent 73d2eacbbd
commit 27200057b8
5 changed files with 69 additions and 41 deletions

View File

@@ -35,7 +35,7 @@ class JavaNetAuthenticator : okhttp3.Authenticator {
val proxy = route?.proxy() ?: Proxy.NO_PROXY
for (challenge in challenges) {
if (!"Basic".equals(challenge.scheme(), ignoreCase = true)) {
if (!"Basic".equals(challenge.scheme, ignoreCase = true)) {
continue
}
@@ -46,8 +46,8 @@ class JavaNetAuthenticator : okhttp3.Authenticator {
proxy.connectToInetAddress(url),
proxyAddress.port,
url.scheme(),
challenge.realm(),
challenge.scheme(),
challenge.realm,
challenge.scheme,
url.url(),
Authenticator.RequestorType.PROXY
)
@@ -57,8 +57,8 @@ class JavaNetAuthenticator : okhttp3.Authenticator {
proxy.connectToInetAddress(url),
url.port(),
url.scheme(),
challenge.realm(),
challenge.scheme(),
challenge.realm,
challenge.scheme,
url.url(),
Authenticator.RequestorType.SERVER
)
@@ -67,7 +67,7 @@ class JavaNetAuthenticator : okhttp3.Authenticator {
if (auth != null) {
val credentialHeader = if (proxyAuthorization) "Proxy-Authorization" else "Authorization"
val credential = Credentials.basic(
auth.userName, String(auth.password), challenge.charset())
auth.userName, String(auth.password), challenge.charset)
return request.newBuilder()
.header(credentialHeader, credential)
.build()