When we use WebClient API from spring-webflux, it internally uses ClientRequest class
But we also have ClientHttpRequest in the spring-web module
Why do we have two different classes that sound & are very similar. Can someone explain the differences between these two classes?
1 Answer
org.springframework.web.reactive.function.client.ClientRequest is meant to be the class that Spring developers can use in with the WebClient. It's got advanced features like a request attributes map, a logPrefix for logging purposes, static builders, etc. It is also using higher level concepts like ExchangeStrategies.
On the other hand, org.springframework.http.client.reactive.ClientHttpRequest is the base abstraction for HTTP client requests, at the raw HTTP level. This is used to implement the various adaptation layers for HTTP clients (Reactor Netty, Jetty).
So unless you're doing with low level stuff, you shouldn't need to use ClientHttpRequest directly in your application.