RFR: 8327796: Add method to java.net.http.HttpRequest to return a GET request in one call [v2]

Daniel Fuchs dfuchs at openjdk.org
Tue Mar 12 16:21:48 UTC 2024


On Tue, 12 Mar 2024 16:15:31 GMT, Michael McMahon <michaelm at openjdk.org> wrote:

>> Hi,
>> 
>> This PR proposes to add simple utility method which returns a simple GET HttpRequest in one call. The current builder pattern requires 4 (or 3 since GET is the default method) method calls to achieve the same effect.
>> 
>> Thanks,
>> Michael
>
> Michael McMahon has updated the pull request incrementally with one additional commit since the last revision:
> 
>   update Daniel review

src/java.net.http/share/classes/java/net/http/HttpRequest.java line 346:

> 344:      * @return a HttpRequest
> 345:      * @throws IllegalArgumentException if the URI scheme is not supported
> 346:      *         or if the uristring is invalid.

Suggestion:

     *         or if the provided {@code uristring} is not a valid URI.

src/java.net.http/share/classes/java/net/http/HttpResponse.java line 153:

> 151:      * @return an Optional containing the response body if the predicate returns true
> 152:      */
> 153:     public Optional<T> bodyWhen(Predicate<ResponseInfo> predicate) throws IOException;

This is a neat idea which will allow to append additional steps like `.orElseThrows(...)` etc...

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/18227#discussion_r1521758012
PR Review Comment: https://git.openjdk.org/jdk/pull/18227#discussion_r1521764029


More information about the net-dev mailing list