DRAFT - HttpRequest.Builder customizer #388
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Provide a way to customize HTTP requests before executing them, for both
HttpClientSseClientTransport
andHttpClientStreamableHttpTransport
.We introduce
AsyncHttpRequestCustomizer
, which is the core class that does the heavy lifting. For blocking contexts, we provide a simplerSyncHttpRequestCustomizer
API, which ultimately gets wrapped. The details of the implementation in both transports is not relevant (yet) ; we are focused on both customizers and also on the transpots, specifically:AsyncHttpRequestCustomizer
SyncHttpRequestCustomizer
HttpClientSseClientTransport.Builder#requestCustomizer
HttpClientStreamableHttpTransport.Builder#requestCustomizer
Motivation and Context
These are transport-level hooks, to allow users to modify request, e.g. to add security in headers (OAuth2 tokens, API keys, etc).
How Has This Been Tested?
Tested with a Servlet Spring app, using
SyncHttpRequestCustomizer
.Breaking Changes
No.
Types of changes
Checklist