murphye / spring-boot-http-3-jetty

How to implement HTTP/3 with Spring Boot and Jetty
11 stars 3 forks source link

Research HTTP/3 Client Implementation using RestClient and WebClient #1

Open murphye opened 1 year ago

murphye commented 1 year ago

https://docs.spring.io/spring-framework/reference/6.1/integration/rest-clients.html#rest-request-factories

https://eclipse.dev/jetty/documentation/jetty-12/programming-guide/index.html#pg-client-http-transport-http3

https://github.com/mdeinum/spring-framework/commit/e02708e1fa905324b4bc9965b02979ce7e22ffee#diff-1a47c2dcb9821b3a6e552fffc302d884a82236f4af77251ac1d34f8eccbfc2f8

It may work something like:

// The HTTP3Client powers the HTTP/3 transport.
HTTP3Client h3Client = new HTTP3Client();
h3Client.getQuicConfiguration().setSessionRecvWindow(64 * 1024 * 1024);

// Create and configure the HTTP/3 transport.
HttpClientTransportOverHTTP3 transport = new HttpClientTransportOverHTTP3(h3Client);

HttpClient client = new HttpClient(transport);

RestClient customClient = RestClient.builder()
  .requestFactory(new JettyClientHttpRequestFactory(client))
  .baseUrl("https://example.com")
  .build();
murphye commented 1 year ago

https://docs.spring.io/spring-framework/reference/web/webflux-webclient/client-builder.html#webflux-client-builder-jetty https://stackoverflow.com/questions/47018963/how-to-use-the-spring-webclient-with-jetty-instead-of-netty https://www.baeldung.com/jetty-reactivestreams-http-client

For the WebClient version it may look like:

// The HTTP3Client powers the HTTP/3 transport.
HTTP3Client h3Client = new HTTP3Client();
h3Client.getQuicConfiguration().setSessionRecvWindow(64 * 1024 * 1024);

// Create and configure the HTTP/3 transport.
HttpClientTransportOverHTTP3 transport = new HttpClientTransportOverHTTP3(h3Client);

HttpClient client = new HttpClient(transport);

WebClient webClient = WebClient.builder()
        .clientConnector(new JettyClientHttpConnector(httpClient))
        .build();