RFR: 8209137: Add ability to bind to specific local address to HTTP client
Daniel Fuchs
dfuchs at openjdk.java.net
Fri Dec 10 09:34:41 UTC 2021
On Fri, 3 Dec 2021 06:15:31 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> This change proposes to implement the enhancement noted in https://bugs.openjdk.java.net/browse/JDK-8209137.
>
> The change introduces a new API to allow applications to build a `java.net.http.HTTPClient` configured with a specific local address that will be used while creating `Socket`(s) for connections.
Generally it would be good if the test did not make any assumption on the presence - or absence - of either IPv4 or IPv6 on the tested machine.
The IPSupport test library class has methods that allows a test to inquire whether IPv6 or IPv4 are available - I would recommend using them to figure out which test cases can be tested on the machine the test runs on.
test/jdk/java/net/httpclient/HttpClientLocalAddrTest.java line 74:
> 72:
> 73: @BeforeClass
> 74: public static void beforeClass() throws Exception {
For HttpClient tests - unless they are specific to HTTP/1.1 I'd recommend making the test class implement HttpServerAdapters and test will all versions of the protocol (http, https, http/2, and https/2).
An example can be found in e.g. `test/jdk/java/net/httpclient/CancelRequestTest.java`
test/jdk/java/net/httpclient/HttpClientLocalAddrTest.java line 205:
> 203: // anyAddress
> 204: if (Boolean.getBoolean("java.net.preferIPv6Addresses")) {
> 205: // ipv6 wildcard
::1 is the ipv6 loopback - not the ipv6 wildcard
-------------
PR: https://git.openjdk.java.net/jdk/pull/6690
More information about the net-dev
mailing list