If any encodeData callbacks call addEncodedData and no StopIteration* return values are returned, the buffered data will never be read, as we never call commonContinue due to the iteration_state_ check in commonHandleAfterDataCallback:
if (status == FilterDataStatus::Continue) {
if (iteration_state_ == IterationState::StopSingleIteration) {
commonHandleBufferData(provided_data);
commonContinue();
return false;
} else {
ASSERT(headers_continued_);
}
This becomes problematic because the following code misbehaves when there's only one encodeData callback:
Http::FilterDataStatus encodeData(Buffer::Instance& data, bool end_stream) {
encoder_callbacks_->addEncodedData(data, false);
if (end_stream) {
encoder_callbacks_->modifyEncodingBuffer([](auto& buffer) {
// do something with the buffer
});
return Http::FilterDataStatus::Continue;
}
return Http::FilterDataStatus::StopIterationNoBuffer;
}
};
Since the first call is has end_stream = true, we add data to buffer but since we return Continue, the buffer is never passed to the next filter.
If any
encodeDatacallbacks calladdEncodedDataand no StopIteration* return values are returned, the buffered data will never be read, as we never callcommonContinuedue to theiteration_state_check incommonHandleAfterDataCallback:This becomes problematic because the following code misbehaves when there's only one
encodeDatacallback:Since the first call is has
end_stream = true, we add data to buffer but since we returnContinue, the buffer is never passed to the next filter.