intellij-ideahttp-proxyintellij-plugin

How to get IntelliJ proxy settings programmatically?


The class HttpConfigurable has been deprecated at version 2024.2, when I use HttpConfigurable.getInstance() to get proxy data such as host, login name, it will warn: 'com. intellij. util. net. HttpConfigurable' is deprecated and marked for removal. Is there other way to get proxy data?

I tried as https://intellij-support.jetbrains.com/hc/en-us/community/posts/206755245-How-to-access-IntelliJ-proxy-data-programmatically said, but warning shows when compiling: warning: [removal] HttpConfigurable in com.intellij.util.net has been deprecated and marked for removal HttpConfigurable proxySettings = HttpConfigurable.getInstance();


Solution

  • The documentation in HttpConfigurable refers you to the deprecation notices for the specific methods:

    /**
    * @deprecated Use {@link ProxySettings}, {@link ProxyAuthentication}, {@link HttpConnectionUtils}, and {@link ProxyUtils} instead.
    * See method deprecation notices for more details.
    * <p/>
    * For removal in version 24.3
    */
    

    For example, according to the documentation for getProxyLogin() states that you should use a version of ProxyUtils#getStaticProxyCredentials.

    /** @deprecated use {@link ProxyUtils#getStaticProxyCredentials(ProxySettings, ProxyCredentialProvider)} or {@link ProxyUtils#setStaticProxyCredentials(ProxySettings, ProxyCredentialStore, Credentials, boolean)} */
      @Deprecated(forRemoval = true)
      @Transient
      public @Nullable String getProxyLogin() {
        return getSecure("proxy.login");
      }