简体   繁体   中英

Configuring org.apache.http.impl.client.DefaultHttpClient to use the default Authenticator

I am attempting to use DefaultHttpClient over a proxy with basic authentication. Setting the client to use the default ProxySelector is (sort of) straight forward:

DefaultHttpClient client = new DefaultHttpClient();
client.setRoutePlanner(new ProxySelectorRoutePlanner(
    client.getConnectionManager().getSchemeRegistry(),
    null));

However, this doesn't configure the client to use the default Authenticator. Is there a way to do this, or am I forced to setup the authentication explicitly?

您可以实现一个自定义CredentialsProvider ,它将用户凭据的解析委派给默认的Authenticator。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM