Closed
Description
DefaultClientResponse
has from(ClientResponse)
which copies status, headers, and cookies. It is only half as useful because it ignores the body which is easy to forget or otherwise leads to code like this as a starting point:
ClientResponse.from(response).body(response.bodyToFlux(DataBuffer.class)
We should add ClientResponse.mutate()
matching to similar options on the server side. Also both client and server mutate()
should be careful not to parse cookies unnecessarily which can lead to surprises, see #24663.
In addition since mutation can be quite common, it should be made as optimal as possible, avoiding object creation in parts not mutated, and also optimizing for repeated use, e.g. response headers).