Armeria WebClient request with connection factory and Req header

302 Views Asked by At

I have been trying to make an https connection using armeria WebClient Since the connection factory is not specified I am getting javax.net.ssl.SSLHandshakeException could anyone help with a relevant example.? Thanks

1

There are 1 best solutions below

0
On BEST ANSWER
  RequestHeaders header = RequestHeaders.of(HttpMethod.GET, endpoint, HttpHeaderNames.COOKIE,
            cookieHeader);
    WebClient.of(clientFactory(), hosturl)
    .execute(header)
    .aggregate()
    .whenCompleteAsync((resp,cause)->{
        if(cause != null) {
           //TODO
        }
        else if(resp.status()==HttpStatus.OK) {
            //TODO
        }
        else
        {
            //TODO
        }


    });




 public static ClientFactory clientFactory() {

    return ClientFactory.builder().sslContextCustomizer(b -> b.trustManager(InsecureTrustManagerFactory.INSTANCE))
            .idleTimeout(Duration.ZERO).build();
}