Polishing contribution

Closes gh-29958
This commit is contained in:
rstoyanchev
2024-03-12 10:40:08 +00:00
parent 8af1d8e842
commit 6767f7010c
10 changed files with 62 additions and 50 deletions

View File

@@ -266,10 +266,7 @@ final class DefaultClientRequestBuilder implements ClientRequest.Builder {
}));
}
Map<String, Object> requestAttributes = request.getAttributes();
if (!this.attributes.isEmpty()) {
this.attributes.forEach((key, value) -> requestAttributes.put(key, value));
}
request.getAttributes().putAll(this.attributes);
if (this.httpRequestConsumer != null) {
this.httpRequestConsumer.accept(request);

View File

@@ -41,7 +41,6 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import io.netty.util.Attribute;
import io.netty.util.AttributeKey;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
@@ -207,13 +206,13 @@ class WebClientIntegrationTests {
StepVerifier.create(result).expectComplete().verify();
if (nativeRequest.get() instanceof ChannelOperations<?,?> nativeReq) {
Attribute<Map<String, Object>> attributes = nativeReq.channel().attr(AttributeKey.valueOf("attributes"));
Attribute<Map<String, Object>> attributes = nativeReq.channel().attr(ReactorClientHttpConnector.ATTRIBUTES_KEY);
assertThat(attributes.get()).isNotNull();
assertThat(attributes.get()).containsEntry("foo", "bar");
}
else if (nativeRequest.get() instanceof reactor.netty5.channel.ChannelOperations<?,?> nativeReq) {
io.netty5.util.Attribute<Map<String, Object>> attributes =
nativeReq.channel().attr(io.netty5.util.AttributeKey.valueOf("attributes"));
nativeReq.channel().attr(ReactorNetty2ClientHttpConnector.ATTRIBUTES_KEY);
assertThat(attributes.get()).isNotNull();
assertThat(attributes.get()).containsEntry("foo", "bar");
}
@@ -221,7 +220,7 @@ class WebClientIntegrationTests {
assertThat(nativeReq.getAttributes()).containsEntry("foo", "bar");
}
else if (nativeRequest.get() instanceof org.apache.hc.core5.http.HttpRequest nativeReq) {
// TODO get attributes from HttpClientContext
// Attributes are not in the request, but in separate HttpClientContext
}
}