Apache 4.3.x按优先顺序记录以下身份验证方案:
[negotiate, Kerberos, NTLM, Digest, Basic]
如何更改此订单?
我尝试了以下内容:
DefaultHttpClient httpclient = new DefaultHttpClient(ccm, params);
// Choose BASIC over DIGEST for proxy authentication
List<String> authpref = new ArrayList<String>();
authpref.add(AuthPolicy.BASIC);
authpref.add(AuthPolicy.DIGEST);
httpclient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);
但这在4.3.X中已被弃用,所以或许更好的问题是如何在4.3.x中执行上述操作?
答案 0 :(得分:3)
这应该大致相当
RequestConfig config = RequestConfig.custom()
.setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.BASIC, AuthSchemes.DIGEST))
.build();
CloseableHttpClient httpClient = HttpClients.custom()
.setDefaultRequestConfig(config)
.build();