When using HttpEntity to make a request with RestTemplate, the HttpHeaders passed to ClientHttpRequestInterceptors is mutable but with immutable values.
Steps to Reproduce
Create a RestTemplate with a ClientHttpRequestInterceptor that adds a value for a particular header
Create an HttpEntity with an HttpHeaders containing a different value for that same header
Make a request using any of the RestTemplate methods that accepts an HttpEntity
An UnsupportedOperationException is thrown.
The request is sent with both values for the header.
After a deeper look, I agree that this half mutable HttpHeaders instance is probably not ideal, and I also think the intent is to provide a mutable headers to the interceptor. I have slightly modified the implementation.
Arjen Poutsma Can you please check that you are ok with the proposed changes?
Sébastien, I see you've made use of part of my PR from a year ago. But the parts you left out fixed this bug for requests that have a body. Was that on purpose? I realize I only added a unit test for requests without a body.
Sébastien, I see that you have now incorporated all the changes from my PR 1277 in your commits 554662e and 73a81f9.
I have closed that PR, but could you please tell me what I should do differently to have my PR approved and merged, if I were to attempt to contribute to Spring Framework another time? Since there was never any feedback on my PR, I simply forgot about it until HerrDerb commented last week.