proxy-wasm / proxy-wasm-cpp-host

WebAssembly for Proxies (C++ host implementation)
Apache License 2.0
84 stars 69 forks source link

setBuffer returns BadArgument when called in onRequestTrailers #331

Open michal-kopczynski opened 1 year ago

michal-kopczynski commented 1 year ago

We have a use case in which we buffer locally part of each body chunk and send it later, together with the following chunk. On the last chunk, we send the remaining part of previous chunk together with the whole last chunk. We do that by modifying buffer using setBuffer function.

This works fine unless the request includes trailers. In such case, last chunk is received in last invocation of onRequestBody, but there is no way to know that this is a last chunk as end_stream == false. And in onRequest/ResponseTrailers setting buffer is not possible (returns BadArgument).