envoyproxy / envoy

Cloud-native high-performance edge/middle/service proxy
https://www.envoyproxy.io
Apache License 2.0
24.71k stars 4.75k forks source link

Support Body Transformations #35783

Open arkodg opened 3 weeks ago

arkodg commented 3 weeks ago

Title: Support Body Transformations

Description:. Envoy supports manipulating/transforming headers, would be great to also support transforming the request and response body to be able to

Relevant Links:

Adding a list of other proxy implementations that support this

arkodg commented 2 weeks ago

would be great if this feature/filter can also support copying/setting fields from the body into the header, allowing routing based on request body which is a AI LLM Gateway use case, more in this doc cc @robscott

wbpcode commented 2 weeks ago

Although it is not encouraged that to mutate request body because it will need to buffer whole body and break the streamlined processing. But I also admit that there are lots of related requirements.

So, SGTM. And I can help to review the design and to sponsor this new extension if someone wants to take this. (note: a design proposal is necessary first).

mathetake commented 2 weeks ago

@wbpcode I will take a shot at this!

mathetake commented 2 weeks ago

/assign

kyessenov commented 2 weeks ago

Although it is not encouraged that to mutate request body because it will need to buffer whole body and break the streamlined processing. But I also admit that there are lots of related requirements.

So, SGTM. And I can help to review the design and to sponsor this new extension if someone wants to take this. (note: a design proposal is necessary first).

I think the technical challenge is to make mutations streaming. It's feasible as long as the body is structured. The buffering approach forces large connection buffers in multiplexed protocols, which is not scaleable for multi-tenant gateways.

wbpcode commented 2 weeks ago

Although it is not encouraged that to mutate request body because it will need to buffer whole body and break the streamlined processing. But I also admit that there are lots of related requirements.

So, SGTM. And I can help to review the design and to sponsor this new extension if someone wants to take this. (note: a design proposal is necessary first).

I think the technical challenge is to make mutations streaming. It's feasible as long as the body is structured. The buffering approach forces large connection buffers in multiplexed protocols, which is not scaleable for multi-tenant gateways.

According to my exp, in the scenarios where this feature is required, the body basically is a JSON. It's almost impossible to make mutations streaming for that.

At least for now, I don't know how to make a general solution for long live stream which has unlimited body length. So, I am inclined to ignore them first.

arkodg commented 2 weeks ago

+1 to @wbpcode's suggestion of keeping streaming, out of scope

kyessenov commented 2 weeks ago

+1 to @wbpcode's suggestion of keeping streaming, out of scope

Yes, I didn't mean to require it. But we should be explicit about the limitations of a buffering approach (e.g. connection buffers must be at least the number of streams per connections \times max buffered bytes). E.g. 1MB JSONs with 100 H2 streams require up to 100MB connection buffers.