Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support http.nonProxyHosts for default proxy in NetHttpTransport #1827

Open
burkedavison opened this issue Mar 3, 2023 · 0 comments
Open
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@burkedavison
Copy link
Contributor

burkedavison commented Mar 3, 2023

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();
@burkedavison burkedavison added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p3 Desirable enhancement or fix. May not be included in next release. labels Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

1 participant