Skip to content

Latest commit

 

History

History
29 lines (20 loc) · 1.4 KB

File metadata and controls

29 lines (20 loc) · 1.4 KB

HTTP Clients

Spring Boot offers a number of starters that work with HTTP clients. This section answers questions related to using them.

Configure RestTemplate to Use a Proxy

As described in io.adoc, you can use a RestTemplateCustomizer with RestTemplateBuilder to build a customized RestTemplate. This is the recommended approach for creating a RestTemplate configured to use a proxy.

The exact details of the proxy configuration depend on the underlying client request factory that is being used.

Configure the TcpClient used by a Reactor Netty-based WebClient

When Reactor Netty is on the classpath a Reactor Netty-based WebClient is auto-configured. To customize the client’s handling of network connections, provide a ClientHttpConnector bean. The following example configures a 60 second connect timeout and adds a ReadTimeoutHandler:

link:{docs-java}/howto/httpclients/webclientreactornettycustomization/MyReactorNettyClientConfiguration.java[role=include]
Tip
Note the use of ReactorResourceFactory for the connection provider and event loop resources. This ensures efficient sharing of resources for the server receiving requests and the client making requests.