镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Support http.nonProxyHosts for default proxy in NetHttpTransport #1827

Open

Description

@burkedavison

https.proxyHost and https.proxyPort are used to create a default proxy when none is explicitly provided.

Oracle documentation on this feature which is linked in our documentation also specifies behavior for http.nonProxyHosts which is not currently supported in the implementation.

Until supported, dynamic proxy behavior can be implemented with a custom ConnectionFactory. Example:

ConnectionFactory connectionFactory = new ConnectionFactory() {
  @Override 
  public HttpURLConnection openConnection(URL url) throws IOException, ClassCastException {
    return shouldUseProxy(url) ? url.openConnection(proxy) : url.openConnection();
  }
  private boolean shouldUseProxy(URL url) { 
    // Implement by parsing http.nonProxyHosts, or with direct logic. 
  }
}

HttpTransport transport = 
  new NetHttpTransport.Builder()
    .setConnectionFactory(connectionFactory)
    // Do not call .setProxy()
    .build();

Activity

  1. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    priority: p3Desirable enhancement or fix. May not be included in next release.
    on Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions