MultiThreadedHttpConnectionManagerでHttpClient 3を使用しています
有効な資格情報でサイトに接続し、無効な資格情報で再度接続すると、2 回目の接続が驚くほど機能します。これは、接続マネージャーがプールされた接続を使用し、既に認証されたホストを再認証しないためだと思います。ただし、無効な資格情報を提供した場合に HttpClient が失敗するようにしたいのですが、どうすればよいですか?
これは私が使用する方法の一部です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()));