public static void main(final String... args)throws Exception {
        final Executor executor = Executor.newInstance()
                .auth(new HttpHost("somehost"), "username", "password".toCharArray())
                .auth(new HttpHost("myproxy", 8080), "username", "password".toCharArray())
                .authPreemptive(new HttpHost("myproxy", 8080));

        // Execute a GET with timeout settings and return response content as String.
        executor.execute(Request.get("http://somehost/")
                .connectTimeout(Timeout.ofSeconds(1)))
                .returnContent().asString();

        // Execute a POST with the 'expect-continue' handshake, using HTTP/1.1,
        // containing a request body as String and return response content as byte array.
        executor.execute(Request.post("http://somehost/do-stuff")
                .useExpectContinue()
                .version(HttpVersion.HTTP_1_1)
                .bodyString("Important stuff", ContentType.DEFAULT_TEXT)
                ).returnContent().asBytes();

        // Execute a POST with a custom header through the proxy containing a request body
        // as an HTML form and save the result to the file
        executor.execute(Request.post("http://somehost/some-form")
                .addHeader("X-Custom-header", "stuff")
                .viaProxy(new HttpHost("myproxy", 8080))
                .bodyForm(Form.form().add("username", "vip").add("password", "secret").build())
                ).saveContent(new File("result.dump"));
    }
This example demonstrates how the he HttpClient fluent API can be used to execute multiple
requests within the same security context. The Executor class maintains a common context shared
by all requests executed with it. The Executor is thread-safe and can be used to execute
requests concurrently from multiple threads of execution.
httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java