-
Notifications
You must be signed in to change notification settings - Fork 41k
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
Add general purpose header support to RestTemplateBuilder #17091
Add general purpose header support to RestTemplateBuilder #17091
Conversation
Hello, Thanks. |
https://ci.spring.io/builds/79665
You have to rebase against |
20f5026
to
baf4021
Compare
Yep, will do. However still curious about the CI login :) |
Yep I am curious too :) |
It is intentional that you can't log in to Concourse. That's only needed for administrative purposes. AFAIK, adding commits or force-pushing should be sufficient to trigger a new build. |
baf4021
to
d905761
Compare
Update `RestTemplateBuilder` so that it is easier to apply custom headers to the outgoing request. The update is particularly useful for setting the `User-Agent` header, for example so that a GitHub username can be used when calling `api.github.com`. See gh-17091
Broaden the scope of customizer support so that instead of focusing just on headers, we can now customize any outgoing `HttpClientRequest`. Also update auto-configuration to automatically add any `RestTemplateRequestCustomizer` beans to the builder. See gh-17091
Thanks for the PR @L00kian! This has now been merged into master. Whilst working on the merge it hit me that we can generalize the customizer even more and one that applies to Thanks again for the contribution! |
Thanks! |
@L00kian I started to get worried that users might call builder.requestCustomizers(customizers).basicAuth("user", "password"); but this version would not: builder.basicAuth("user", "password").requestCustomizers(customizers); In the end I decided to make the |
See #17072 for details.
Added convenience methods for customising the
RestTemplate
builtHttpHeaders
handling. The #17010 approach was taken as a baseline. The underlyingBasicAuthenticationClientHttpRequestFactory
reworked to accept any number ofHttpHeadersCustomizer
instances to handle http request headers. Added convenience methods toRestTemplateBuilder
to populate a 'default header' as well as customHttpHeadersCustomizer
implementations. Refactored #17010 changes to follow the sameHttpHeadersCustomizer
concept