@@ -191,6 +191,7 @@ public void failed(final Exception ex) {
191191 public void cancelled () {
192192 asyncExecCallback .failed (new InterruptedIOException ());
193193 }
194+
194195 }));
195196 } else {
196197 if (execRuntime .isEndpointConnected ()) {
@@ -199,6 +200,7 @@ public void cancelled() {
199200 proceedToNextHop (state , request , entityProducer , scope , chain , asyncExecCallback );
200201 }
201202 }
203+
202204 }
203205
204206 private void proceedToNextHop (
@@ -235,6 +237,7 @@ private void doProceedToNextHop(
235237 switch (step ) {
236238 case HttpRouteDirector .CONNECT_TARGET :
237239 operation .setDependency (execRuntime .connectEndpoint (clientContext , new FutureCallback <AsyncExecRuntime >() {
240+
238241 @ Override
239242 public void completed (final AsyncExecRuntime execRuntime ) {
240243 tracker .connectTarget (route .isSecure ());
@@ -253,11 +256,13 @@ public void failed(final Exception ex) {
253256 public void cancelled () {
254257 asyncExecCallback .failed (new InterruptedIOException ());
255258 }
259+
256260 }));
257261 break ;
258262
259263 case HttpRouteDirector .CONNECT_PROXY :
260264 operation .setDependency (execRuntime .connectEndpoint (clientContext , new FutureCallback <AsyncExecRuntime >() {
265+
261266 @ Override
262267 public void completed (final AsyncExecRuntime execRuntime ) {
263268 final HttpHost proxy = route .getProxyHost ();
@@ -277,6 +282,7 @@ public void failed(final Exception ex) {
277282 public void cancelled () {
278283 asyncExecCallback .failed (new InterruptedIOException ());
279284 }
285+
280286 }));
281287 break ;
282288
@@ -290,11 +296,16 @@ public void cancelled() {
290296 break ;
291297
292298 case HttpRouteDirector .TUNNEL_PROXY :
299+ // The most simple example for this case is a proxy chain
300+ // of two proxies, where P1 must be tunnelled to P2.
301+ // route: Source -> P1 -> P2 -> Target (3 hops)
302+ // fact: Source -> P1 -> Target (2 hops)
293303 asyncExecCallback .failed (new HttpException ("Proxy chains are not supported" ));
294304 break ;
295305
296306 case HttpRouteDirector .LAYER_PROTOCOL :
297307 execRuntime .upgradeTls (clientContext , new FutureCallback <AsyncExecRuntime >() {
308+
298309 @ Override
299310 public void completed (final AsyncExecRuntime asyncExecRuntime ) {
300311 if (LOG .isDebugEnabled ()) {
@@ -313,6 +324,7 @@ public void failed(final Exception ex) {
313324 public void cancelled () {
314325 asyncExecCallback .failed (new InterruptedIOException ());
315326 }
327+
316328 });
317329 break ;
318330
@@ -337,7 +349,7 @@ private void createTunnel(
337349 final State state ,
338350 final HttpHost proxy ,
339351 final HttpHost nextHop ,
340- final HttpRoute route , // NEW
352+ final HttpRoute route ,
341353 final AsyncExecChain .Scope scope ,
342354 final AsyncExecCallback asyncExecCallback ) {
343355
@@ -381,7 +393,7 @@ public void cancel() {
381393 @ Override
382394 public void produceRequest (final RequestChannel requestChannel ,
383395 final HttpContext httpContext ) throws HttpException , IOException {
384- final BasicHttpRequest connect = new BasicHttpRequest (Method .CONNECT , nextHop , nextHop .toHostString ());
396+ final HttpRequest connect = new BasicHttpRequest (Method .CONNECT , nextHop , nextHop .toHostString ());
385397 connect .setVersion (HttpVersion .HTTP_1_1 );
386398
387399 // --- RFC 7639: inject ALPN header (if provided) ----------------
@@ -408,7 +420,8 @@ public int available() {
408420 }
409421
410422 @ Override
411- public void consumeInformation (final HttpResponse r , final HttpContext c ) throws HttpException , IOException {
423+ public void consumeInformation (final HttpResponse httpResponse ,
424+ final HttpContext httpContext ) throws HttpException , IOException {
412425 }
413426
414427 @ Override
@@ -476,6 +489,7 @@ public void streamEnd(final List<? extends Header> trailers) throws HttpExceptio
476489 } else {
477490 operation .setDependency (execRuntime .execute (exchangeId , internalExchangeHandler , clientContext ));
478491 }
492+
479493 }
480494
481495 private boolean needAuthentication (
@@ -528,4 +542,5 @@ private void proceedConnected(
528542 asyncExecCallback .failed (ex );
529543 }
530544 }
545+
531546}
0 commit comments