envoyproxy / envoy

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

Can ext proc support modify body according to headers value for each request? #37259

Open StarryVae opened 2 days ago

StarryVae commented 2 days ago

Title: Can ext proc support modify body according to headers value?

Description:

for example, the external server want to update body according to the value of header A for each request, can ext proc support now? thanks!

StarryVae commented 2 days ago

cc @tyxia @yanjunxiang-google @stevenzzzz as code owners, thanks.

yanjunxiang-google commented 1 day ago

Yes, the filter can be configured to not send body. When the server sends the header response, it overrides the body processing mode to be "STREAMED": https://github.com/envoyproxy/envoy/blob/64036b42e1581df185d02858d0e5d48b8aaaef97/api/envoy/service/ext_proc/v3/external_processor.proto#L187.

StarryVae commented 1 day ago

@yanjunxiang-google thanks, but maybe i didn't describe the issue clearly, what i want to do is modify body according to the value of header for each request in the ext server, For example, if the value of header foo is a, we set the body to a.

tyxia commented 1 day ago

@StarryVae CONTINUE_AND_REPLACE is probably what you want

StarryVae commented 1 day ago

@tyxia yes, and i want to modify the request json body like {"foo":"bar", "test":"test"......}, if the value of header foo is a, we set the foo in body to a, so the ext server must have the value of request header and body at the same time? How cat i achieve this? thanks!

tyxia commented 1 day ago

send_body_without_waiting_for_header_response enables you to receive both header and body

StarryVae commented 1 day ago

oh, i see it in 1.32, maybe my Envoy version is old, thanks a lot! @tyxia

StarryVae commented 1 day ago

by the way, does ext proc has some ext server examples? thanks!

StarryVae commented 1 day ago

send_body_without_waiting_for_header_response enables you to receive both header and body

and it seems that the ext server has to associate the header and body of the same request?