Skip to content

codemonstur/httpclient

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Release Maven Central MIT Licence

HttpClient

A wrapper around the Java 11 HttpClient that makes for nicer code.

With some tweaking you can get this:

static class RecaptchaResponse { boolean success; String challenge_ts; String hostname; }

public static void main(final String... args) throws IOException {
    final var response = newHttpCall()
        .scheme("https").hostname("www.google.com").port(443)
        .post("/recaptcha/api/siteverify")
        .body(newFormBody()
            .add("secret", "1234567890")
            .add("response", "response"))
        .execute()
        .verifyNotServerError()
        .verifySuccess()
        .fetchBodyInto(RecaptchaResponse.class);
}

It's in Maven Central

<dependency>
    <groupId>com.github.codemonstur</groupId>
    <artifactId>httpclient</artifactId>
    <version>1.2.2</version>
</dependency>