HTTPCLIENT-1446: NTLM proxy + BASIC target auth fails with 'Unexpected state: MSG_TYPE3_GENERATED

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1557064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2014-01-10 09:29:13 +00:00
parent 502908d501
commit 1fe5fa3c2e
3 changed files with 31 additions and 19 deletions

View File

@ -10,6 +10,10 @@ Users of HttpClient 4.3 are encouraged to upgrade.
Changelog:
-------------------
* [HTTPCLIENT-1446] NTLM proxy + BASIC target auth fails with 'Unexpected state:
MSG_TYPE3_GENERATED'.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* [HTTPCLIENT-1443] HttpCache uses the physical host instead of the virtual host as a cache key.
Contributed by Francois-Xavier Bonnet <fx at apache.org>

View File

@ -1026,22 +1026,26 @@ protected RoutedRequest handleResponse(final RoutedRequest roureq,
final Scheme scheme = connManager.getSchemeRegistry().getScheme(target);
target = new HttpHost(target.getHostName(), scheme.getDefaultPort(), target.getSchemeName());
}
if (this.authenticator.isAuthenticationRequested(target, response,
this.targetAuthStrategy, this.targetAuthState, context)) {
final boolean targetAuthRequested = this.authenticator.isAuthenticationRequested(
target, response, this.targetAuthStrategy, targetAuthState, context);
HttpHost proxy = route.getProxyHost();
// if proxy is not set use target host instead
if (proxy == null) {
proxy = route.getTargetHost();
}
final boolean proxyAuthRequested = this.authenticator.isAuthenticationRequested(
proxy, response, this.proxyAuthStrategy, proxyAuthState, context);
if (targetAuthRequested) {
if (this.authenticator.authenticate(target, response,
this.targetAuthStrategy, this.targetAuthState, context)) {
// Re-try the same request via the same route
return roureq;
}
}
HttpHost proxy = route.getProxyHost();
if (this.authenticator.isAuthenticationRequested(proxy, response,
this.proxyAuthStrategy, this.proxyAuthState, context)) {
// if proxy is not set use target host instead
if (proxy == null) {
proxy = route.getTargetHost();
}
if (proxyAuthRequested) {
if (this.authenticator.authenticate(proxy, response,
this.proxyAuthStrategy, this.proxyAuthState, context)) {
// Re-try the same request via the same route

View File

@ -544,18 +544,22 @@ private boolean needAuthentication(
route.getTargetHost().getPort(),
target.getSchemeName());
}
if (this.authenticator.isAuthenticationRequested(target, response,
this.targetAuthStrategy, targetAuthState, context)) {
final boolean targetAuthRequested = this.authenticator.isAuthenticationRequested(
target, response, this.targetAuthStrategy, targetAuthState, context);
HttpHost proxy = route.getProxyHost();
// if proxy is not set use target host instead
if (proxy == null) {
proxy = route.getTargetHost();
}
final boolean proxyAuthRequested = this.authenticator.isAuthenticationRequested(
proxy, response, this.proxyAuthStrategy, proxyAuthState, context);
if (targetAuthRequested) {
return this.authenticator.handleAuthChallenge(target, response,
this.targetAuthStrategy, targetAuthState, context);
}
HttpHost proxy = route.getProxyHost();
if (this.authenticator.isAuthenticationRequested(proxy, response,
this.proxyAuthStrategy, proxyAuthState, context)) {
// if proxy is not set use target host instead
if (proxy == null) {
proxy = route.getTargetHost();
}
if (proxyAuthRequested) {
return this.authenticator.handleAuthChallenge(proxy, response,
this.proxyAuthStrategy, proxyAuthState, context);
}