Skip to content

Commit 754bcbc

Browse files
committed
refactor: drop proxy-authentication handling from NodeRuntimeManager
Keep the download path simple: OkHttp still picks up IDE proxy host/port settings via the default ProxySelector, but authenticated proxies are no longer handled specially. When the download fails the plugin gracefully falls back to a bundled or system Node.js as before.
1 parent 5d21040 commit 754bcbc

1 file changed

Lines changed: 0 additions & 37 deletions

File tree

jetbrains_plugin/src/main/kotlin/org/zoocode/jetbrains/core/NodeRuntimeManager.kt

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,10 @@ import com.intellij.openapi.progress.Task
1212
import com.intellij.openapi.application.PathManager
1313
import com.intellij.openapi.util.SystemInfo
1414
import com.intellij.util.io.Decompressor
15-
import okhttp3.Authenticator
16-
import okhttp3.Credentials
1715
import okhttp3.OkHttpClient
1816
import okhttp3.Request
19-
import okhttp3.Response
20-
import okhttp3.Route
2117
import java.io.File
2218
import java.io.IOException
23-
import java.net.HttpURLConnection
24-
import java.net.InetSocketAddress
2519
import java.security.MessageDigest
2620
import java.util.concurrent.TimeUnit
2721
import java.util.concurrent.locks.ReentrantLock
@@ -52,41 +46,10 @@ object NodeRuntimeManager {
5246
private val httpClient = OkHttpClient.Builder()
5347
.connectTimeout(15, TimeUnit.SECONDS)
5448
.readTimeout(60, TimeUnit.SECONDS)
55-
.proxyAuthenticator(IdeProxyAuthenticator)
5649
.build()
5750

5851
private val downloadLock = ReentrantLock()
5952

60-
/**
61-
* Proxy authenticator that resolves credentials through java.net.Authenticator,
62-
* which the IDE populates with its configured proxy credentials
63-
*/
64-
private object IdeProxyAuthenticator : Authenticator {
65-
override fun authenticate(route: Route?, response: Response): Request? {
66-
if (response.code != HttpURLConnection.HTTP_PROXY_AUTH) {
67-
return null
68-
}
69-
val proxyAddress = route?.proxy?.address() as? InetSocketAddress ?: return null
70-
val passwordAuthentication = java.net.Authenticator.requestPasswordAuthentication(
71-
proxyAddress.hostString,
72-
proxyAddress.address,
73-
proxyAddress.port,
74-
"http",
75-
null,
76-
"http",
77-
response.request.url.toUrl(),
78-
java.net.Authenticator.RequestorType.PROXY
79-
) ?: return null
80-
val credential = Credentials.basic(
81-
passwordAuthentication.userName,
82-
String(passwordAuthentication.password)
83-
)
84-
return response.request.newBuilder()
85-
.header("Proxy-Authorization", credential)
86-
.build()
87-
}
88-
}
89-
9053
/**
9154
* Platform-specific Node.js distribution descriptor
9255
*/

0 commit comments

Comments
 (0)