The ClientResponse currenly does not provide an accessor to the HttpRequest object for which it was built.

This could be useful on (ExchangeFilterFunction)(https://github.com/spring-projects/spring-framework/blob/main/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ExchangeFilterFunction.java) when handling redirects that happen at the TcpClient level.

Take for example the following sample:

    public Mono<ClientResponse> filter(ClientRequest request, ExchangeFunction next)
    {
        return next.exchange(request)
                   .doOnSubscribe(s -> {
                       logger.info("--> " + request.method() + ' ' + request.url()); //1
                   })
                   .doOnError(error -> logger.info("<-- HTTP FAILED", error))
                   .timed()
                   .map(timed -> {
                       var tookMs = timed.elapsed().toMillis();
                       var response = timed.get(); //2
                       logger.info("<-- {} {}", response.statusCode(), request.url());
                       return response;
                   });
    }

In the line "1", I print the URL being requested originally, however the URL that it was finally used could be different on "2" if a redirect was followed. At the moment, there isn't a way of accessing that information from the ClientResponse object.

Comment From: rstoyanchev

I don't see why we couldn't do that, and there is already a method on ClientResponse#Builder to set the request. Having the corresponding accessor to then expose it from the created ClientResponse makes sense.