You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
modify response headers values based on response body contents #62
Is it possible to modify response header values based on response body contents? For example, if I match a certain pattern in onResponseBody I want to replace :status header value from 200 to 401 or 403 value.
According to documentation, Header API is only effective from onRequestHeader/onResponseHeader. So my task seems to be impossible to implement. Or maybe you can point to some kind of workaround?
I have a similar use case. We need to update crc-32 header after we modify response body. However, according to the docs, header modification is not allowed when we process body.
Is there a workaround available?
@PiotrSikora thank you for your suggestion of using HTTP trailers! I tried to use them in my sandbox project, but onResponseTrailers and onRequestTrailers are not being called. Do you have any example of how to use them?
Here is what I have in my Context:
@PiotrSikora thank you for your suggestion of using HTTP trailers! I tried to use them in my sandbox project, but onResponseTrailers and onRequestTrailers are not being called. Do you have any example of how to use them?
Those callbacks are called only if trailers already exist (i.e. if they were received from upstream)... and I've now realized that we don't support setting trailers if they don't already exist in Envoy, see: envoyproxy/envoy#15831.
Activity
aysee commentedon Apr 1, 2021
I have a similar use case. We need to update crc-32 header after we modify response body. However, according to the docs, header modification is not allowed when we process body.
Is there a workaround available?
PiotrSikora commentedon Apr 2, 2021
@webngt buffering complete responses is not supported, sorry (see: proxy-wasm/proxy-wasm-cpp-host#143 (comment)).
@aysee if the consumer supports it, then you should be sending updated CRC-32 value in HTTP trailers instead of headers.
aysee commentedon Apr 3, 2021
@PiotrSikora thank you for your suggestion of using HTTP trailers! I tried to use them in my sandbox project, but onResponseTrailers and onRequestTrailers are not being called. Do you have any example of how to use them?
Here is what I have in my Context:
Here is the implementation itself (just logs for debug purposes):
on*Body methods also return FilterDataStatus::Continue
PiotrSikora commentedon Apr 3, 2021
Those callbacks are called only if trailers already exist (i.e. if they were received from upstream)... and I've now realized that we don't support setting trailers if they don't already exist in Envoy, see: envoyproxy/envoy#15831.
PiotrSikora commentedon Apr 16, 2021
@aysee that PR was merged and it's included in the Envoy v1.18.0 release. There are examples for how to use it in that PR.
aysee commentedon Apr 19, 2021
@PiotrSikora thank you so much for such a quick implementation! I appreciate it!