Small question regarding how to send HTTP2 requests using Webflux WebClient please.
One of our third party API did an upgrade, and they now support HTTP2.
Hence, I believe on my side, as a client, it is worth it to leverage this upgrade.
However, currently, I believe I am sending only HTTP1. To confirm, I saw the access log on the third party side, and it seems the requests are indeed HTTP1.
I have a WebClient bean, and using the bean to send requests.
WebClient.create().mutate().defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).clientConnector(new ReactorClientHttpConnector(HttpClient.create().wiretap(true).secure(sslContextSpec -> sslContextSpec.sslContext(getSslContext())))).build()
public Mono<ThirdPartyResponse> sendAnHTTP2RequestToThirdParty(ThirdPartyRequest request, Map<String, String> headers) {
return webClient.mutate()
.baseUrl(configuration.getThirdPartyUrl())
.build()
.post()
.uri(ROUTE_ThirdParty)
.headers(httpHeaders -> httpHeaders.setAll(headers))
.contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(request))
.retrieve()
.bodyToMono(ThirdPartyResponse.class);
}
What are the configuration, or the code that I am missing please?
Thank you
question from:
https://stackoverflow.com/questions/65947451/java-spring-webflux-webclient-send-http-request-using-http2 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…