Skip to content

Interceptor improvements #122

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

Merged
merged 5 commits into from
May 11, 2025
Merged

Interceptor improvements #122

merged 5 commits into from
May 11, 2025

Conversation

vietj
Copy link
Member

@vietj vietj commented May 11, 2025

  • Unify body and head interceptor in a single builder
  • Add max buffered size during body interception
  • Handle body and head interception failures
  • Body transformer should accept and produce a media type
  • Make the BodyTransformer asynchronous instead of being synchronous

vietj added 4 commits May 8, 2025 17:27
- Add max buffered size during body interception
- Handle body and head interception failures

Motivation:

The body and head interception API can be unified further more by providing a single interceptor instead of two interceptors.

The current body transformation API assumes buffering and therefore uses buffer cumulation, therefore it should have an upper bound regarding this cumulation.

The interceptor implementation does not handle failures such as a transformation failure or a buffer overflow.
Motivation:

Currently body transformer are applied on the media type whatsoever.

A body transformer should declare the list of media type it produces as well as indicate which media type it consumes.

These should be taken in account when applying the body transformer or not on the proxied stream.

Changes:

Add a body transformer produces/consumes method.

The generic proxy interceptor uses the produces/consumes to decide whether or not to apply the transformer based on the response accept header.

The Body interface has been added a media type that indicates the media type of the body entity which can be used to match against transformers and also let the transformer set a body with a different media type.
Motivation:

The design of BodyTransformer is synchronous as currently it only applies to buffering functions.

We should make this contract asynchronous and move the synchronous part in the implementations we currently support.

Changes:

BodyTransform transforms Body->Future<Body> instead of Buffer->Buffer

Synchronous transformations are moved to a BodyTransfomers class

Buffering overflow moves to the synchronous transformer instead of being in the interceptor since now the interceptor only sees an asynchronous transformation.
@vietj vietj added this to the 5.0.0 milestone May 11, 2025
@vietj vietj self-assigned this May 11, 2025
@vietj vietj merged commit e6aa55c into main May 11, 2025
5 checks passed
@vietj vietj deleted the simplify-creation-of-interceptors branch May 11, 2025 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant