envoyproxy / envoy

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

hcm: Allow filter to control on emitting trailers (e.g. to skip encoding trailers when empty) #12374

Open dio opened 4 years ago

dio commented 4 years ago

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 <length=28, flags=0x00, stream_id=13>
[  5.040] recv DATA frame <length=52, flags=0x00, stream_id=13>
[  5.053] recv HEADERS frame <length=0, flags=0x05, stream_id=13>
          ; END_STREAM | END_HEADERS

What we want is something like:

[  5.036] recv DATA frame <length=28, flags=0x00, stream_id=13>
[  5.040] recv DATA frame <length=52, flags=0x00, stream_id=13>
          ; 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.
  2. add end_stream flags to addEncodedData, end stream there and encodeTrailers return StopIteration

From the discussion here, the second of the options above is preferable and when doing that we should do a parallel fix in addDecodedData too.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or other activity occurs. Thank you for your contributions.