New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not replace a request factory when creating a new TestRestTemplate
with withBasicAuth
#15982
Conversation
@nosan Thanks for the PR but I don't think this is how we intended to fix it. We want to avoid using the same I think what we'd want to do instead is use the supplier to create a new instance of the custom |
I agree with your analysis @mbhave (and sorry about the late reply, that notification got lost in my inbox). |
@mbhave |
@nosan in the current PR, Several HTTP client libraries are caching the authentication information at the connection pooling level. This means that reusing the same request factory will result in sending the Cookie request header even if the authentication was not meant to be included. Creating a brand new instance of the configured request factory class (or as Madhura mentioned, falling back to the current behavior in case of problems) should avoid those issues. You can look at the |
…estTemplate` with a `withBasicAuth`. spring-projectsgh-15443
This commit updates the behavior of withBasicAuth on TestRestTemplate by trying to use the same request factory type as the underlying restTemplate. If creation of a new instance of the configured request factory class fails, it falls back to the `ClientHttpRequestFactorySupplier`. See gh-15982
* pr/15982: Polish "Fix request factory used with withBasicAuth" Fix request factory used with TestRestTemplate withBasicAuth
Thanks again, @nosan. This is now on master along with this additional test. |
@mbhave Thanks! |
See gh-15443