Skip to content

Commit 399d78c

Browse files
author
oleksiys
committed
[master] + fix issue AsyncHttpClient#637
AsyncHttpClient#637 "AHC with Grizzly provider not handling SSL Connect/tunnelling with Proxy"
1 parent 4ae7bc9 commit 399d78c

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

providers/grizzly/src/main/java/org/asynchttpclient/providers/grizzly/EventHandler.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
import java.util.Locale;
5656
import java.util.Map;
5757
import java.util.concurrent.TimeUnit;
58+
import org.glassfish.grizzly.Buffer;
59+
import org.glassfish.grizzly.http.HttpRequestPacket;
5860

5961
public final class EventHandler {
6062

@@ -304,6 +306,19 @@ public void onHttpHeadersParsed(HttpHeader httpHeader, FilterChainContext ctx) {
304306

305307
}
306308

309+
public boolean onHttpHeaderParsed(final HttpHeader httpHeader,
310+
final Buffer buffer, final FilterChainContext ctx) {
311+
final HttpRequestPacket request = ((HttpResponsePacket) httpHeader).getRequest();
312+
if (Method.CONNECT.equals(request.getMethod())) {
313+
// finish request/response processing, because Grizzly itself
314+
// treats CONNECT traffic as part of request-response processing
315+
// and we don't want it be treated like that
316+
httpHeader.setExpectContent(false);
317+
}
318+
319+
return false;
320+
}
321+
307322
@SuppressWarnings("rawtypes")
308323
public boolean onHttpPacketParsed(HttpHeader httpHeader, FilterChainContext ctx) {
309324

providers/grizzly/src/main/java/org/asynchttpclient/providers/grizzly/filters/AsyncHttpClientEventFilter.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.io.IOException;
2424
import org.asynchttpclient.providers.grizzly.filters.events.GracefulCloseEvent;
25+
import org.glassfish.grizzly.Buffer;
2526
import org.glassfish.grizzly.filterchain.FilterChainEvent;
2627
import org.glassfish.grizzly.filterchain.NextAction;
2728
import org.glassfish.grizzly.http.HttpResponsePacket;
@@ -111,6 +112,13 @@ protected void onHttpHeadersParsed(HttpHeader httpHeader, FilterChainContext ctx
111112
eventHandler.onHttpHeadersParsed(httpHeader, ctx);
112113
}
113114

115+
@Override
116+
protected boolean onHttpHeaderParsed(final HttpHeader httpHeader,
117+
final Buffer buffer, final FilterChainContext ctx) {
118+
super.onHttpHeaderParsed(httpHeader, buffer, ctx);
119+
return eventHandler.onHttpHeaderParsed(httpHeader, buffer, ctx);
120+
}
121+
114122
@Override
115123
protected boolean onHttpPacketParsed(HttpHeader httpHeader, FilterChainContext ctx) {
116124
return eventHandler.onHttpPacketParsed(httpHeader, ctx);

providers/grizzly/src/main/java/org/asynchttpclient/providers/grizzly/filters/ProxyFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private String generateAuthHeader(final Realm realm) {
100100
case BASIC:
101101
return computeBasicAuthentication(realm);
102102
case DIGEST:
103-
return computeDigestAuthentication(proxyServer);
103+
return computeDigestAuthentication(realm);
104104
case NTLM:
105105
return NTLM_ENGINE.generateType1Msg("NTLM " + realm.getNtlmDomain(), realm.getNtlmHost());
106106
default:

providers/grizzly/src/main/java/org/asynchttpclient/providers/grizzly/filters/TunnelFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013 Sonatype, Inc. All rights reserved.
2+
* Copyright (c) 2013-2014 Sonatype, Inc. All rights reserved.
33
*
44
* This program is licensed to you under the Apache License Version 2.0,
55
* and you may not use this file except in compliance with the Apache License Version 2.0.
@@ -94,7 +94,7 @@ public NextAction handleEvent(FilterChainContext ctx, FilterChainEvent event) th
9494
suspendedContext.resume(ctx.getInvokeAction());
9595

9696
// Stop further event processing.
97-
ctx.getStopAction();
97+
return ctx.getStopAction();
9898
}
9999
return ctx.getInvokeAction();
100100
}

0 commit comments

Comments
 (0)