java Apache HttpClient 3,多线程,每个请求具有不同的凭据
我正在与多线程HttpConnectionManager一起使用HttpClient 3
如果我使用有效凭据连接到站点 然后使用无效凭据再次连接,第二个连接令人惊讶地工作。我假设这是因为连接管理器使用池连接,并且不重新验证已验证的主机。 但是,如果我提供了无效的凭据,我希望HttpClient失败,我该如何做呢
t这是我如何使用HttpClient
的一部分:
//run on each call
HttpClient httpClient = new HttpClient(getMultiThreadedHttpConnectionManagerSingleton());
....
httpClient.getState().setCredentials(
authscope,
new NTCredentials(
ntlmCredentials.getUsername(),//here i give wrong creds on the second attempt
ntlmCredentials.getPassword(),
localHostName, ntlmCredentials.getDomain()));
共 (0) 个答案