Propagate WebClient attributes into underlying HTTP client request where possible
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 theorg.eclipse.jetty.client.api.Request#attribute(String, Object)method one by oneReactorClientHttpRequest: A singleMap<String, Object>containing all request attributes is set to the Attributeattributesin thereactor.netty.channel.ChannelOperations#channel()(as proposed by https://github.com/spring-projects/spring-framework/issues/26208#issuecomment-783324482)ReactorNetty2ClientHttpRequest: Same as inReactorClientHttpRequest, but with thenetty5classesHttpComponentsClientHttpRequest: Attributes are set with theorg.apache.hc.client5.http.protocol.HttpClientContext#setAttribute(String, Object)method one by oneJdkClientHttpRequest: I still need some input on this one. As far as I can see there is no possibility to set request attributes to thejava.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.
@rstoyanchev would love some feedback if you have the time.