Skip to content

Commit ba1a0a4

Browse files
committed
removing log lines and un-necessary code
1 parent 26b59e3 commit ba1a0a4

File tree

1 file changed

+13
-89
lines changed

1 file changed

+13
-89
lines changed

providers/grizzly/src/main/java/com/ning/http/client/providers/grizzly/GrizzlyAsyncHttpProvider.java

Lines changed: 13 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@
126126
import com.ning.http.client.filter.ResponseFilter;
127127
import com.ning.http.client.listener.TransferCompletionHandler;
128128
import com.ning.http.client.ntlm.NTLMEngine;
129-
import com.ning.http.client.ntlm.NTLMEngineException;
130129
import com.ning.http.client.websocket.WebSocket;
131130
import com.ning.http.client.websocket.WebSocketByteListener;
132131
import com.ning.http.client.websocket.WebSocketCloseCodeReasonListener;
@@ -552,7 +551,7 @@ boolean sendRequest(final FilterChainContext ctx,
552551
throws IOException {
553552

554553
boolean isWriteComplete = true;
555-
LOGGER.debug("@@@@@@@@@@@@@@@@@@@@@ sendRequest sending message .... context = "+ctx + " connection is "+ctx.getConnection());
554+
556555
if (requestHasEntityBody(request)) {
557556
final HttpTransactionContext context = getHttpTransactionContext(ctx.getConnection());
558557
BodyHandler handler = bodyHandlerFactory.getBodyHandler(request);
@@ -840,8 +839,6 @@ private boolean sendAsGrizzlyRequest(final Request request,
840839
final FilterChainContext ctx)
841840
throws IOException {
842841

843-
//LOGGER.debug("@@@@@@@@@@@@@@@@@@@@@ sendAsGrizzlyRequest sending message .... context = "+ctx + " connection is "+ctx.getConnection());
844-
845842
final HttpTransactionContext httpCtx = getHttpTransactionContext(ctx.getConnection());
846843
if (isUpgradeRequest(httpCtx.handler) && isWSRequest(httpCtx.requestUrl)) {
847844
httpCtx.isWSRequest = true;
@@ -916,7 +913,7 @@ private boolean sendAsGrizzlyRequest(final Request request,
916913
boolean avoidProxy = ProxyUtils.avoidProxy(proxy, request);
917914
if (!avoidProxy) {
918915
if (!requestPacket.getHeaders().contains(Header.ProxyConnection)) {
919-
requestPacket.setHeader(Header.ProxyConnection, "Keep-Alive");
916+
requestPacket.setHeader(Header.ProxyConnection, "keep-alive");
920917
}
921918

922919
if(proxy.getNtlmDomain() != null && proxy.getNtlmDomain().length() > 0)
@@ -928,10 +925,6 @@ private boolean sendAsGrizzlyRequest(final Request request,
928925

929926
}
930927
}
931-
932-
String userAgent = "Apache-HttpClient/4.2.2 (java 1.5)";
933-
requestPacket.setHeader(Header.UserAgent, userAgent);
934-
935928
final AsyncHandler h = httpCtx.handler;
936929
if (h != null) {
937930
if (TransferCompletionHandler.class.isAssignableFrom(h.getClass())) {
@@ -940,15 +933,7 @@ private boolean sendAsGrizzlyRequest(final Request request,
940933
TransferCompletionHandler.class.cast(h).transferAdapter(new GrizzlyTransferAdapter(map));
941934
}
942935
}
943-
944-
boolean returnVal = false;
945-
try{
946-
returnVal = sendRequest(ctx, request, requestPacket);
947-
}catch(RuntimeException e)
948-
{
949-
e.printStackTrace();
950-
}
951-
return returnVal;
936+
return sendRequest(ctx, request, requestPacket);
952937

953938
}
954939

@@ -1005,7 +990,7 @@ private void addHeaders(final Request request,
1005990

1006991
final MimeHeaders headers = requestPacket.getHeaders();
1007992
if (!headers.contains(Header.Connection)) {
1008-
requestPacket.addHeader(Header.Connection, "Keep-Alive");
993+
requestPacket.addHeader(Header.Connection, "keep-alive");
1009994
}
1010995

1011996
if (!headers.contains(Header.Accept)) {
@@ -1186,10 +1171,7 @@ protected void onHttpContentEncoded(HttpContent content, FilterChainContext ctx)
11861171
protected void onInitialLineParsed(HttpHeader httpHeader,
11871172
FilterChainContext ctx) {
11881173

1189-
11901174
super.onInitialLineParsed(httpHeader, ctx);
1191-
1192-
LOGGER.debug("printing ..... RESPONSE: {}", httpHeader);
11931175
if (httpHeader.isSkipRemainder()) {
11941176
return;
11951177
}
@@ -1243,10 +1225,7 @@ protected void onInitialLineParsed(HttpHeader httpHeader,
12431225
getURI(context.requestUrl),
12441226
provider);
12451227
context.responseStatus = responseStatus;
1246-
LOGGER.debug("auth header "+httpHeader.getHeader(Header.ProxyAuthenticate));
1247-
LOGGER.debug("############### status handler is not null....so returning here "+context.statusHandler);
12481228
if (context.statusHandler != null) {
1249-
12501229
return;
12511230
}
12521231
if (context.currentState != AsyncHandler.STATE.ABORT) {
@@ -1296,7 +1275,6 @@ protected void onHttpHeadersParsed(HttpHeader httpHeader,
12961275
final HttpTransactionContext context = provider.getHttpTransactionContext(ctx.getConnection());
12971276

12981277
if (httpHeader.isSkipRemainder() || (context.establishingTunnel && context.statusHandler==null)) {
1299-
LOGGER.debug("returning skipping remainder");
13001278
return;
13011279
}
13021280

@@ -1412,7 +1390,6 @@ protected void onHttpHeadersParsed(HttpHeader httpHeader,
14121390
protected boolean onHttpPacketParsed(HttpHeader httpHeader, FilterChainContext ctx) {
14131391

14141392
boolean result;
1415-
LOGGER.debug("onHttpPacketParsed "+ctx + " http header = "+httpHeader);
14161393
final String proxy_auth = httpHeader.getHeader(Header.ProxyAuthenticate);
14171394

14181395
if (httpHeader.isSkipRemainder() ) {
@@ -1422,21 +1399,8 @@ protected boolean onHttpPacketParsed(HttpHeader httpHeader, FilterChainContext c
14221399
cleanup(ctx, provider);
14231400
return false;
14241401
}else{
1425-
LOGGER.debug("!!!!!! onHttpPacketParsed this is second handshake so not cleaning up");
14261402
super.onHttpPacketParsed(httpHeader, ctx);
14271403
httpHeader.getProcessingState().setKeepAlive(true);
1428-
/*final HttpTransactionContext context = provider.getHttpTransactionContext(ctx.getConnection());
1429-
final AsyncHandler handler = context.handler;
1430-
if (handler != null) {
1431-
try {
1432-
context.result(handler.onCompleted());
1433-
} catch (Exception e) {
1434-
context.abort(e);
1435-
}
1436-
} else {
1437-
context.done(null);
1438-
}*/
1439-
LOGGER.debug("!!!!!! onHttpPacketParsed this is second handshake so not cleaning up ctx = "+ctx);
14401404
return false;
14411405
}
14421406
}
@@ -1548,16 +1512,14 @@ private static final class AuthorizationHandler implements StatusHandler {
15481512

15491513

15501514
public boolean handlesStatus(int statusCode) {
1551-
LOGGER.debug("inside handle status returning = "+HttpStatus.UNAUTHORIZED_401.statusMatches(statusCode));
15521515
return (HttpStatus.UNAUTHORIZED_401.statusMatches(statusCode));
15531516
}
15541517

15551518
@SuppressWarnings({"unchecked"})
15561519
public boolean handleStatus(final HttpResponsePacket responsePacket,
15571520
final HttpTransactionContext httpTransactionContext,
15581521
final FilterChainContext ctx) {
1559-
1560-
LOGGER.debug("inside handle status returning context = "+ctx);
1522+
15611523
final String auth = responsePacket.getHeader(Header.WWWAuthenticate);
15621524
if (auth == null) {
15631525
throw new IllegalStateException("401 response received, but no WWW-Authenticate header was present");
@@ -1640,16 +1602,14 @@ private static final class ProxyAuthorizationHandler implements StatusHandler {
16401602

16411603

16421604
public boolean handlesStatus(int statusCode) {
1643-
LOGGER.debug("inside proxy handle status returning "+HttpStatus.PROXY_AUTHENTICATION_REQUIRED_407.statusMatches(statusCode));
16441605
return (HttpStatus.PROXY_AUTHENTICATION_REQUIRED_407.statusMatches(statusCode));
16451606
}
16461607

16471608
@SuppressWarnings({"unchecked"})
16481609
public boolean handleStatus(final HttpResponsePacket responsePacket,
16491610
final HttpTransactionContext httpTransactionContext,
16501611
final FilterChainContext ctx) {
1651-
1652-
LOGGER.debug("inside proxy handle status returning context = "+ctx);
1612+
16531613
final String proxy_auth = responsePacket.getHeader(Header.ProxyAuthenticate);
16541614
if (proxy_auth == null) {
16551615
throw new IllegalStateException("407 response received, but no Proxy Authenticate header was present");
@@ -1689,27 +1649,16 @@ public boolean handleStatus(final HttpResponsePacket responsePacket,
16891649

16901650
req.getHeaders().remove(Header.ProxyAuthenticate.toString());
16911651
req.getHeaders().remove(Header.ProxyAuthorization.toString());
1692-
req.getHeaders().remove(Header.Accept.toString());
1693-
req.getHeaders().remove("CLIENT_ID");
1652+
16941653
String msg = null;
16951654
try {
16961655

1697-
if(proxy_auth.toLowerCase().equals("ntlm"))
1656+
if(isFirstHandShake(proxy_auth))
16981657
{
1699-
17001658
msg = ntlmEngine.generateType1Msg(proxyServer.getNtlmDomain(), "");
1701-
//msg = ApacheNTLMWrapper.generateType1Msg(proxyServer.getNtlmDomain(), "");
1702-
17031659
}else {
17041660
String serverChallenge = proxy_auth.trim().substring("NTLM ".length());
1705-
//String serverChallenge1 = "TlRMTVNTUAACAAAAEgASADAAAAA1AokgNc3mBXra8i8AAAAAAAAAAIgAiABCAAAAUwBGAEQAQwBQAFIATwBYAFkAAgASAFMARgBEAEMAUABSAE8AWABZAAEAEgBJAFAAQQBTAEUAUgBWAEUAUgAEAB4AcwBmAGQAYwBwAHIAbwB4AHkALgBsAG8AYwBhAGwAAwAyAGkAcABhAHMAZQByAHYAZQByAC4AcwBmAGQAYwBwAHIAbwB4AHkALgBsAG8AYwBhAGwAAAAAAA==";
1706-
//System.out.println("Server Challenge :: " + serverChallenge);
1707-
//System.out.println("Server Challenge1 :: " + serverChallenge1);
1708-
1709-
17101661
msg = ntlmEngine.generateType3Msg(principal, password, proxyServer.getNtlmDomain(), proxyServer.getHost(), serverChallenge);
1711-
//msg = ApacheNTLMWrapper.generateType3Msg(principal, password, proxyServer.getNtlmDomain(), "", serverChallenge);
1712-
//msg = "TlRMTVNTUAADAAAAGAAYAEAAAAC0ALQAWAAAABIAEgAMAQAACgAKAB4BAAAAAAAAKAEAAAAAAAAoAQAANQIIIGYSPmcl/CPV8YAkN+5e1A1MmwI0Ekz0aS41p9y413TiBLJA82wTL4UBAQAAAAAAAJD+rq/r8s0BTJsCNBJM9GkAAAAAAgASAFMARgBEAEMAUABSAE8AWABZAAEAEgBJAFAAQQBTAEUAUgBWAEUAUgAEAB4AcwBmAGQAYwBwAHIAbwB4AHkALgBsAG8AYwBhAGwAAwAyAGkAcABhAHMAZQByAHYAZQByAC4AcwBmAGQAYwBwAHIAbwB4AHkALgBsAG8AYwBhAGwAAAAAAFMARgBEAEMAUABSAE8AWABZAHUAcwBlAHIANQA=";
17131662
}
17141663

17151664
req.getHeaders().add(Header.ProxyAuthorization.toString(), "NTLM " + msg);
@@ -1724,14 +1673,7 @@ public boolean handleStatus(final HttpResponsePacket responsePacket,
17241673
InvocationStatus tempInvocationStatus = InvocationStatus.STOP;
17251674

17261675
try {
1727-
1728-
/*if(proxy_auth.toLowerCase().startsWith("ntlm") && !isSecondHandShake(proxy_auth))
1729-
{
1730-
httpTransactionContext.done(null);
1731-
}*/
1732-
1733-
if(proxy_auth.toLowerCase().startsWith("ntlm"))
1734-
//if(isSecondHandShake(proxy_auth))
1676+
if(isFirstHandShake(proxy_auth))
17351677
{
17361678
tempInvocationStatus = InvocationStatus.CONTINUE;
17371679

@@ -1742,9 +1684,6 @@ public boolean handleStatus(final HttpResponsePacket responsePacket,
17421684
final Connection c = ctx.getConnection();
17431685
final HttpTransactionContext newContext = httpTransactionContext.copy(); //httpTransactionContext.copy();
17441686

1745-
tempInvocationStatus = InvocationStatus.STOP;
1746-
1747-
LOGGER.debug("is connection cacheable "+m.isConnectionCacheable(c));
17481687
httpTransactionContext.future = null;
17491688
httpTransactionContext.provider.setHttpTransactionContext(c, newContext);
17501689

@@ -1763,23 +1702,6 @@ public boolean handleStatus(final HttpResponsePacket responsePacket,
17631702
return false;
17641703
}
17651704

1766-
/*final Connection c = m.obtainConnection(req, httpTransactionContext.future);
1767-
final HttpTransactionContext newContext = httpTransactionContext.copy();
1768-
httpTransactionContext.future = null;
1769-
httpTransactionContext.provider.setHttpTransactionContext(c, newContext);
1770-
1771-
newContext.invocationStatus = tempInvocationStatus;
1772-
1773-
try {
1774-
httpTransactionContext.provider.execute(c,
1775-
req,
1776-
httpTransactionContext.handler,
1777-
httpTransactionContext.future);
1778-
return false;
1779-
} catch (IOException ioe) {
1780-
newContext.abort(ioe);
1781-
return false;
1782-
}*/
17831705
}
17841706
else{
17851707
final Connection c = m.obtainConnection(req, httpTransactionContext.future);
@@ -1809,8 +1731,11 @@ public boolean handleStatus(final HttpResponsePacket responsePacket,
18091731

18101732
public static boolean isSecondHandShake(final String proxy_auth) {
18111733
return (proxy_auth.toLowerCase().startsWith("ntlm") && !proxy_auth.equalsIgnoreCase("ntlm"));
1812-
//return proxy_auth.toLowerCase().startsWith("ntlm");
18131734
}
1735+
public static boolean isFirstHandShake(final String proxy_auth) {
1736+
return (proxy_auth.equalsIgnoreCase("ntlm"));
1737+
}
1738+
18141739

18151740
} // END AuthorizationHandler
18161741

@@ -2740,7 +2665,6 @@ public boolean acquire() {
27402665
@Override
27412666
public void onClosed(Connection connection, Connection.CloseType closeType) throws IOException {
27422667

2743-
LOGGER.debug("!!!!!!!!!!!!!!!! close getting invoked..... connection = "+connection+" closetype "+closeType);
27442668
if (connections != null) {
27452669
connections.release();
27462670
}

0 commit comments

Comments
 (0)