Skip to content

Several fixes for the Grizzly provider. #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 22, 2011
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reformat, no functional changes
  • Loading branch information
jfarcand authored and rlubke committed Sep 21, 2011
commit 568d097a05e6693cc3f2aba0de4818a81024a737
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ private static HttpRequest construct(AsyncHttpClientConfig config,
if (!(auth != null && auth.size() > 0 && auth.get(0).startsWith("NTLM"))) {
try {
String msg = ntlmEngine.generateType1Msg(proxyServer.getNtlmDomain(),
proxyServer.getHost());
proxyServer.getHost());
nettyRequest.setHeader(HttpHeaders.Names.PROXY_AUTHORIZATION, "NTLM " + msg);
} catch (NTLMEngineException e) {
IOException ie = new IOException();
Expand All @@ -647,7 +647,7 @@ private static HttpRequest construct(AsyncHttpClientConfig config,
}
} else {
nettyRequest.setHeader(HttpHeaders.Names.PROXY_AUTHORIZATION,
AuthenticatorUtils.computeBasicAuthentication(proxyServer));
AuthenticatorUtils.computeBasicAuthentication(proxyServer));
}
}
}
Expand Down Expand Up @@ -845,12 +845,12 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand

boolean useSSl = uri.getScheme().compareToIgnoreCase(HTTPS) == 0 && proxyServer == null;
if (channel != null && channel.isOpen() && channel.isConnected()) {
HttpRequest nettyRequest = buildRequest(config, request, uri, f == null ? false : f.isConnectAllowed(), bufferedBytes);
HttpRequest nettyRequest = buildRequest(config, request, uri, f == null ? false : f.isConnectAllowed(), bufferedBytes);

if (f == null) {
f = newFuture(uri, request, asyncHandler, nettyRequest, config, this);
} else {
nettyRequest = buildRequest(config, request, uri, f.isConnectAllowed(), bufferedBytes);
nettyRequest = buildRequest(config, request, uri, f.isConnectAllowed(), bufferedBytes);
f.setNettyRequest(nettyRequest);
}
f.setState(NettyResponseFuture.STATE.POOLED);
Expand Down Expand Up @@ -927,10 +927,9 @@ private <T> ListenableFuture<T> doConnect(final Request request, final AsyncHand
}

try {
if (request.getInetAddress() != null) {
channelFuture = bootstrap.connect(new InetSocketAddress(request.getInetAddress(), AsyncHttpProviderUtils.getPort(uri)));
}
else if (proxyServer == null || avoidProxy) {
if (request.getInetAddress() != null) {
channelFuture = bootstrap.connect(new InetSocketAddress(request.getInetAddress(), AsyncHttpProviderUtils.getPort(uri)));
} else if (proxyServer == null || avoidProxy) {
channelFuture = bootstrap.connect(new InetSocketAddress(AsyncHttpProviderUtils.getHost(uri), AsyncHttpProviderUtils.getPort(uri)));
} else {
channelFuture = bootstrap.connect(new InetSocketAddress(proxyServer.getHost(), proxyServer.getPort()));
Expand Down Expand Up @@ -1181,7 +1180,7 @@ public Object call() throws Exception {
log.debug("Sending proxy authentication to {}", request.getUrl());

future.setState(NettyResponseFuture.STATE.NEW);

if (!proxyAuth.contains("Kerberos") && (proxyAuth.get(0).contains("NTLM") || (proxyAuth.contains("Negotiate")))) {
newRealm = ntlmProxyChallenge(proxyAuth, request, proxyServer, headers, realm, future);
// SPNEGO KERBEROS
Expand Down Expand Up @@ -1409,14 +1408,14 @@ private Realm ntlmChallenge(List<String> wwwAuth,
realmBuilder = new Realm.RealmBuilder();
}
newRealm = realmBuilder.setScheme(realm.getAuthScheme())
.setUri(URI.create(request.getUrl()).getPath())
.setMethodName(request.getMethod())
.build();
.setUri(URI.create(request.getUrl()).getPath())
.setMethodName(request.getMethod())
.build();
}

return newRealm;
}

private Realm ntlmProxyChallenge(List<String> wwwAuth,
Request request,
ProxyServer proxyServer,
Expand All @@ -1429,10 +1428,10 @@ private Realm ntlmProxyChallenge(List<String> wwwAuth,
if (wwwAuth.get(0).startsWith("NTLM ")) {
String serverChallenge = wwwAuth.get(0).trim().substring("NTLM ".length());
String challengeHeader = ntlmEngine.generateType3Msg(proxyServer.getPrincipal(),
proxyServer.getPassword(),
proxyServer.getNtlmDomain(),
proxyServer.getHost(),
serverChallenge);
proxyServer.getPassword(),
proxyServer.getNtlmDomain(),
proxyServer.getHost(),
serverChallenge);
headers.add(HttpHeaders.Names.PROXY_AUTHORIZATION, "NTLM " + challengeHeader);
}
Realm newRealm;
Expand All @@ -1443,9 +1442,9 @@ private Realm ntlmProxyChallenge(List<String> wwwAuth,
realmBuilder = new Realm.RealmBuilder();
}
newRealm = realmBuilder//.setScheme(realm.getAuthScheme())
.setUri(URI.create(request.getUrl()).getPath())
.setMethodName(request.getMethod())
.build();
.setUri(URI.create(request.getUrl()).getPath())
.setMethodName(request.getMethod())
.build();

return newRealm;
}
Expand Down