hcm: Allow filter to control on emitting trailers (e.g. to skip encoding trailers when empty)
- Dominant language
- C++
- Stars
- 28.9k
- Forks
- 5.6k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 437
Description
Context: Some of the filters, e.g. gRPC Web requires to skip encoding trailers due to https://github.com/envoyproxy/envoy/issues/10514.
i.e. currently, we have the following "problematic" response frames.
```
[ 5.036] recv DATA frame
[ 5.040] recv DATA frame
[ 5.053] recv HEADERS frame
; END_STREAM | END_HEADERS
```
What we want is something like:
```
[ 5.036] recv DATA frame
[ 5.040] recv DATA frame
; END_STREAM
```
We have the current data frames since we always encode trailers. The proposed solution will be to have control from the filter side.
A couple of options:
1. introduce a new return enum to `FilterTrailersStatus`, to indicate that trailers should not be emitted.
1. add `end_stream` flags to `addEncodedData`, end stream there and `encodeTrailers` return `StopIteration`
From the discussion [here](https://github.com/envoyproxy/envoy/pull/12178#discussion_r459932842), the second of the options above is preferable and when doing that we should do a parallel fix in `addDecodedData` too.
Contributor guide
Assessment
This issue has not been assessed yet.