Skip to content

Commit cc58cd1

Browse files
committed
Improve javadoc
1 parent f4e976a commit cc58cd1

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
/**
4343
* Codec for the HTTP {@code ALPN} header field (RFC 7639).
4444
*
45-
* @since 5.4
45+
* @since 5.6
4646
*/
4747
@Contract(threading = ThreadingBehavior.IMMUTABLE)
4848
@Internal

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,20 @@ public final HttpAsyncClientBuilder disableRequestPriority() {
914914
return this;
915915
}
916916

917+
/**
918+
* Configures the {@code ALPN} header to be sent on {@code CONNECT}
919+
* requests when establishing an HTTP tunnel through a proxy.
920+
*
921+
* <p>The supplied protocol IDs are advertised in the given order (preference order).
922+
* If {@code ids} is {@code null} or empty, no {@code ALPN} header will be added.</p>
923+
*
924+
* <p>This is a convenience method equivalent to installing a {@link ConnectAlpnProvider}
925+
* that always returns the same list.</p>
926+
*
927+
* @param ids ALPN protocol IDs to advertise (for example {@code "h2"} and {@code "http/1.1"})
928+
* @return this builder
929+
* @since 5.6
930+
*/
917931
public HttpAsyncClientBuilder setConnectAlpn(final String... ids) {
918932
final List<String> list = ids != null && ids.length > 0 ? Arrays.asList(ids) : Collections.emptyList();
919933
this.connectAlpnProvider = (t, r) -> list;

httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,20 @@ public final HttpClientBuilder setProxySelector(final ProxySelector proxySelecto
812812
return this;
813813
}
814814

815+
/**
816+
* Configures the {@code ALPN} header to be sent on {@code CONNECT}
817+
* requests when establishing an HTTP tunnel through a proxy.
818+
*
819+
* <p>The supplied protocol IDs are advertised in the given order (preference order).
820+
* If {@code ids} is {@code null} or empty, no {@code ALPN} header will be added.</p>
821+
*
822+
* <p>This is a convenience method equivalent to installing a {@link ConnectAlpnProvider}
823+
* that always returns the same list.</p>
824+
*
825+
* @param ids ALPN protocol IDs to advertise (for example {@code "h2"} and {@code "http/1.1"})
826+
* @return this builder
827+
* @since 5.6
828+
*/
815829
public HttpClientBuilder setConnectAlpn(final String... ids) {
816830
final List<String> list = ids != null && ids.length > 0 ? Arrays.asList(ids) : Collections.emptyList();
817831
this.connectAlpnProvider = (t, r) -> list;

httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClassicConnectAlpnEndToEndDemo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.io.InputStream;
3232
import java.io.InputStreamReader;
3333
import java.io.OutputStream;
34+
import java.net.InetAddress;
3435
import java.net.InetSocketAddress;
3536
import java.net.ServerSocket;
3637
import java.net.Socket;
@@ -91,7 +92,7 @@ public static void main(final String[] args) throws Exception {
9192
final int originPort = origin.getLocalPort();
9293

9394
// ---- Tiny blocking proxy printing ALPN and tunneling bytes
94-
final ServerSocket proxyServer = new ServerSocket(0, 50, java.net.InetAddress.getByName("127.0.0.1"));
95+
final ServerSocket proxyServer = new ServerSocket(0, 50, InetAddress.getByName("127.0.0.1"));
9596
final int proxyPort = proxyServer.getLocalPort();
9697
final ExecutorService proxyPool = Executors.newCachedThreadPool();
9798
proxyPool.submit(() -> {

0 commit comments

Comments
 (0)