This PR Closes #26208
As proposed by @tstavinoha (https://github.com/spring-projects/spring-framework/issues/26208#issuecomment-739817950) and @rstoyanchev (https://github.com/spring-projects/spring-framework/issues/26208#issuecomment-783324482), this adds the option applyAttributes
to the WebClient.Builder
. If it is set to true
, the ClientRequest.attributes()
will be copied over to the underlying http-client library HttpRequest. For this there are different implementations for the various ClientHttpConnector
implementations:
* JettyClientHttpRequest
: Attributes are set with the org.eclipse.jetty.client.api.Request#attribute(String, Object)
method one by one
* ReactorClientHttpRequest
: A single Map<String, Object>
containing all request attributes is set to the Attribute attributes
in the reactor.netty.channel.ChannelOperations#channel()
(as proposed by https://github.com/spring-projects/spring-framework/issues/26208#issuecomment-783324482)
* ReactorNetty2ClientHttpRequest
: Same as in ReactorClientHttpRequest
, but with the netty5
classes
* HttpComponentsClientHttpRequest
: Attributes are set with the org.apache.hc.client5.http.protocol.HttpClientContext#setAttribute(String, Object)
method one by one
* JdkClientHttpRequest
: I still need some input on this one. As far as I can see there is no possibility to set request attributes to the java.net.http.HttpRequest
?
As suggested by https://github.com/spring-projects/spring-framework/issues/26208#issuecomment-739817950, applyAttributes
defaults to true
and the user can opt-out when using the Builder to create the Connector.
Comment From: PhilKes
@rstoyanchev would love some feedback if you have the time.