-
Notifications
You must be signed in to change notification settings - Fork 29
Description
(This issue is semi-related to #64 "HTTP: add control of the end_of_stream flag", arguably they could be coalesced)
In its section on Buffers, the v0.2.1 ABI spec says:
Access to buffers (listed in proxy_buffer_type_t) using functions in this section is restricted to specific callbacks:
- HTTP_REQUEST_BODY can be read and modified in proxy_on_request_body (or for as long as request processing is paused from it).
- HTTP_RESPONSE_BODY can be read and modified in proxy_on_response_body (or for as long as response processing is paused from it).
However, in the case of an HTTP request that does not contain a body, or (more rarely) an HTTP response without a body, a plugin will receive a proxy_on_request_headers or proxy_on_response_headers callback with end_of_stream=true, and won't see a proxy_on_*_body callback. This means that if the plugin wants to add a body to the request/response being proxied, it has no way of doing so, since it would need to access the HTTP_REQUEST_BODY or HTTP_RESPONSE_BODY buffer, which is not available.
Some possible solutions:
-
A. Allow proxy_on_request_headers to access the HTTP_REQUEST_BODY buffer in the case where end_of_stream=true.
-
B. Specify that the host should call proxy_on_request_headers(..., end_of_stream=false) followed by proxy_on_request_body(body_size=0, end_of_stream=true).
-
C. Add hostcalls corresponding to Envoy's StreamDecoderFilterCallbacks::addDecodedData and StreamEncoderFilterCallbacks::addEncodedData methods.
Among these, (A) seems appealing in that it is a minor change that might even be possible to introduce in the current ABI without breaking plugins. (B) would be a more visible behavior change, and (C) seems less uniform (and more Envoy-specific) WRT the existing setBuffer API.