We could avoid the following kind of common builder boilerplate
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://foo.com/index.html"))
.GET()
.build();
by adding a method to HttpRequest as follows:
/***
* Returns a GET HttpRequest to the given URI.
*
* @throws URISyntaxException if the string cannot be converted to a URI
*/
public static HttpRequest GET(String uri) {}
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://foo.com/index.html"))
.GET()
.build();
by adding a method to HttpRequest as follows:
/***
* Returns a GET HttpRequest to the given URI.
*
* @throws URISyntaxException if the string cannot be converted to a URI
*/
public static HttpRequest GET(String uri) {}
- csr for
-
JDK-8328600 Add method to java.net.http.HttpRequest to return a GET request in one call
-
- Draft
-
- links to
-
Review openjdk/jdk/18227