Invoke defaultRequest earlier in RestClient and WebClient
Closes gh-32053
This commit is contained in:
@@ -528,6 +528,23 @@ public class DefaultWebClientTests {
|
||||
StepVerifier.create(responsePublisher).expectError(WebClientResponseException.class).verify();
|
||||
}
|
||||
|
||||
@Test // gh-32053
|
||||
void defaultRequestOverride() {
|
||||
WebClient client = this.builder
|
||||
.defaultRequest(spec -> spec.accept(MediaType.APPLICATION_JSON))
|
||||
.build();
|
||||
|
||||
client.get().uri("/path")
|
||||
.accept(MediaType.IMAGE_PNG)
|
||||
.retrieve()
|
||||
.bodyToMono(Void.class)
|
||||
.block(Duration.ofSeconds(3));
|
||||
|
||||
ClientRequest request = verifyAndGetRequest();
|
||||
assertThat(request.headers().getAccept()).containsExactly(MediaType.IMAGE_PNG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ClientRequest verifyAndGetRequest() {
|
||||
ClientRequest request = this.captor.getValue();
|
||||
|
||||
Reference in New Issue
Block a user