What would you like to be added?
As pointed out in #129334 (comment) existing implementation of deferredResponseWriter assumes a single write when deciding whether gzip encoding is needed. We would extend writes to allow multiple calls to Write.
To support multiple calls to Write and still make an accurate decision about whether to enable gzip encoding, we will need to buffer the response until its size reach the gzip threshold defaultGzipThresholdBytes or Close is called. At that point we can flush the buffer as it's no longer needed.
As a prerequisite to this change we developed a test to validate the current chunking behavior in #130190. As part of this PR we want to flip expectGzip flag to true as part of "two small chunk writes" scenario. Context #130190 (comment)
Why is this needed?
Required to implement response streaming described in https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/5116-streaming-response-encoding#streaming-collections-and-gzip-encoding
Tracked in kubernetes/enhancements#5116
What would you like to be added?
As pointed out in #129334 (comment) existing implementation of deferredResponseWriter assumes a single write when deciding whether gzip encoding is needed. We would extend writes to allow multiple calls to
Write.To support multiple calls to
Writeand still make an accurate decision about whether to enablegzipencoding, we will need to buffer the response until its size reach the gzip thresholddefaultGzipThresholdBytesorCloseis called. At that point we can flush the buffer as it's no longer needed.As a prerequisite to this change we developed a test to validate the current chunking behavior in #130190. As part of this PR we want to flip
expectGzipflag to true as part of"two small chunk writes"scenario. Context #130190 (comment)Why is this needed?
Required to implement response streaming described in https://github.com/kubernetes/enhancements/tree/master/keps/sig-api-machinery/5116-streaming-response-encoding#streaming-collections-and-gzip-encoding
Tracked in kubernetes/enhancements#5116