Skip to content

Expose the WebTestClient assigned request id header as a public constant [SPR-15575] #20134

@spring-projects-issues

Description

@spring-projects-issues

Andy Wilkinson opened SPR-15575 and commented

Assuming my understanding of the API is correct, I would expect this test to pass:

@Test
public void requestHeadersFromWebFilterAreAvailableFromExchangeResult() {
    RouterFunction<ServerResponse> route = RouterFunctions
            .route(RequestPredicates.GET("/"), (request) -> {
                Assert.notEmpty(request.headers().header("FOO"), "FOO is required");
                return ServerResponse.status(HttpStatus.OK).build();
            });
    WebTestClient client = WebTestClient.bindToRouterFunction(route)
            .webFilter((exchange, chain) -> {
                return chain.filter(exchange.mutate().request((builder) -> {
                    builder.header("FOO", "bar");
                }).build());
            }).build();

    client.get().uri("/").exchange().expectStatus().isOk();
    assertThat(client.get().uri("/").exchange().expectBody().returnResult()
            .getRequestHeaders().getFirst("FOO"), is(notNullValue()));
}

It fails (with both RC1 and the latest snapshot) on the assertion at the end which checks that the FOO header is present in the ExchangeResult's request headers.


Affects: 5.0 RC1

Referenced from: commits 204a9cf

Metadata

Metadata

Assignees

Labels

in: testIssues in the test moduletype: taskA general task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions