Fix for HTTPCLIENT-1833

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/branches/4.5.x@1787433 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Karl Wright 2017-03-17 16:04:02 +00:00 committed by Oleg Kalnichevski
parent 7ff6b6c438
commit a2a581eba1
2 changed files with 13 additions and 2 deletions

View File

@ -8,6 +8,9 @@ Please note that as of 4.4 HttpClient requires Java 1.6 or newer.
Changelog: Changelog:
------------------- -------------------
* [HTTPCLIENT-1833] Fix Windows Negotiate-NTLM handling of proxies.
Contributed by Roman Stoffel <roman.stoffel at gamler.info>
* [HTTPCLIENT-1817] Add a "Trust All" TrustStrategy implementation. * [HTTPCLIENT-1817] Add a "Trust All" TrustStrategy implementation.
Contributed by Gary Gregory <ggregory at apache.org> Contributed by Gary Gregory <ggregory at apache.org>

View File

@ -241,10 +241,18 @@ public class WindowsNegotiateScheme extends AuthSchemeBase {
final String spn; final String spn;
if (this.servicePrincipalName != null) { if (this.servicePrincipalName != null) {
spn = this.servicePrincipalName; spn = this.servicePrincipalName;
} else if(isProxy()){
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final RouteInfo route = clientContext.getHttpRoute();
if (route != null) {
spn = "HTTP/" + route.getProxyHost().getHostName();
} else {
// Should not happen
spn = null;
}
} else { } else {
final HttpClientContext clientContext = HttpClientContext.adapt(context); final HttpClientContext clientContext = HttpClientContext.adapt(context);
final HttpHost target = clientContext.getTargetHost(); final HttpHost target = clientContext.getTargetHost(); if (target != null) {
if (target != null) {
spn = "HTTP/" + target.getHostName(); spn = "HTTP/" + target.getHostName();
} else { } else {
final RouteInfo route = clientContext.getHttpRoute(); final RouteInfo route = clientContext.getHttpRoute();