Skip to content

Commit 14d11db

Browse files
committed
Add javadoc
1 parent f4678bd commit 14d11db

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/H2OverH2TunnelSupport.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ public final class H2OverH2TunnelSupport {
6262
private H2OverH2TunnelSupport() {
6363
}
6464

65+
/**
66+
* Establishes a CONNECT tunnel and returns the resulting {@link ProtocolIOSession}
67+
* via the callback. The tunnel session supports optional TLS upgrade.
68+
*
69+
* @param proxySession the HTTP/2 session to the proxy
70+
* @param target the target endpoint for the CONNECT request authority
71+
* @param connectTimeout timeout for the CONNECT handshake
72+
* @param secure whether to upgrade the tunnel to TLS after establishment
73+
* @param tlsStrategy TLS strategy for the upgrade (required when {@code secure} is true)
74+
* @param callback completion callback receiving the tunnel session
75+
* @since 5.7
76+
*/
6577
public static void establish(
6678
final IOSession proxySession,
6779
final NamedEndpoint target,
@@ -72,6 +84,19 @@ public static void establish(
7284
establishInternal(proxySession, target, connectTimeout, secure, tlsStrategy, null, null, callback);
7385
}
7486

87+
/**
88+
* Establishes a CONNECT tunnel with a request interceptor for injecting
89+
* headers (e.g. proxy authentication) into the CONNECT request.
90+
*
91+
* @param proxySession the HTTP/2 session to the proxy
92+
* @param target the target endpoint for the CONNECT request authority
93+
* @param connectTimeout timeout for the CONNECT handshake
94+
* @param secure whether to upgrade the tunnel to TLS after establishment
95+
* @param tlsStrategy TLS strategy for the upgrade (required when {@code secure} is true)
96+
* @param connectRequestInterceptor interceptor applied to the CONNECT request before sending
97+
* @param callback completion callback receiving the tunnel session
98+
* @since 5.7
99+
*/
75100
public static void establish(
76101
final IOSession proxySession,
77102
final NamedEndpoint target,
@@ -83,6 +108,20 @@ public static void establish(
83108
establishInternal(proxySession, target, connectTimeout, secure, tlsStrategy, connectRequestInterceptor, null, callback);
84109
}
85110

111+
/**
112+
* Establishes a CONNECT tunnel and starts a protocol handler inside it.
113+
* The protocol starter factory creates an {@link org.apache.hc.core5.reactor.IOEventHandler}
114+
* that is connected to the tunnel session immediately after establishment.
115+
*
116+
* @param proxySession the HTTP/2 session to the proxy
117+
* @param target the target endpoint for the CONNECT request authority
118+
* @param connectTimeout timeout for the CONNECT handshake
119+
* @param secure whether to upgrade the tunnel to TLS after establishment
120+
* @param tlsStrategy TLS strategy for the upgrade (required when {@code secure} is true)
121+
* @param protocolStarter factory for the protocol handler to run inside the tunnel
122+
* @param callback completion callback receiving the tunnel session
123+
* @since 5.7
124+
*/
86125
public static void establish(
87126
final IOSession proxySession,
88127
final NamedEndpoint target,
@@ -94,6 +133,21 @@ public static void establish(
94133
establish(proxySession, target, connectTimeout, secure, tlsStrategy, null, protocolStarter, callback);
95134
}
96135

136+
/**
137+
* Establishes a CONNECT tunnel with both a request interceptor and a protocol starter.
138+
* This is the most general overload combining proxy authentication support with
139+
* automatic protocol initialization inside the tunnel.
140+
*
141+
* @param proxySession the HTTP/2 session to the proxy
142+
* @param target the target endpoint for the CONNECT request authority
143+
* @param connectTimeout timeout for the CONNECT handshake
144+
* @param secure whether to upgrade the tunnel to TLS after establishment
145+
* @param tlsStrategy TLS strategy for the upgrade (required when {@code secure} is true)
146+
* @param connectRequestInterceptor interceptor applied to the CONNECT request before sending
147+
* @param protocolStarter factory for the protocol handler to run inside the tunnel
148+
* @param callback completion callback receiving the tunnel session
149+
* @since 5.7
150+
*/
97151
public static void establish(
98152
final IOSession proxySession,
99153
final NamedEndpoint target,

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/TunnelRefusedException.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,33 @@ public final class TunnelRefusedException extends HttpException {
4444

4545
private final HttpResponse response;
4646

47+
/**
48+
* Creates a new exception from the proxy response that refused the tunnel.
49+
*
50+
* @param response the non-2xx CONNECT response from the proxy
51+
* @since 5.7
52+
*/
4753
public TunnelRefusedException(final HttpResponse response) {
4854
super("Tunnel refused: " + new StatusLine(Args.notNull(response, "Response")));
4955
this.response = copy(response);
5056
}
5157

58+
/**
59+
* Returns a defensive copy of the proxy response that refused the tunnel.
60+
*
61+
* @return the proxy response
62+
* @since 5.7
63+
*/
5264
public HttpResponse getResponse() {
5365
return response;
5466
}
5567

68+
/**
69+
* Returns the HTTP status code of the proxy response.
70+
*
71+
* @return the status code (e.g. 407 for proxy authentication required)
72+
* @since 5.7
73+
*/
5674
public int getStatusCode() {
5775
return response.getCode();
5876
}

0 commit comments

Comments
 (0)