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).

Comment From: SenthilPanneerselvam

Hi Rossen, Are you working on this issue? If not I would like to pick this up. I also have a question related to this, Can you please explain me what does matching to similar options on the server side mean in "We should add ClientResponse.mutate() matching to similar options on the server side."

Comment From: rstoyanchev

@SenthilPanneerselvam thanks for the offer to help. I'd afraid the issue is such that it requires a little experimenting but actual changes expected are not much. So by the time I can give you a proper answer I'd probably have the solution more or less ready.