You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.
Based on the content of the response body, I want to either
Stream the response body as it is
Send HTTP/1.1 403 Forbidden response by using proxywasm.SendHttpResponse.
func (ctx *httpFTC) OnHttpResponseBody(bodySize int, endOfStream bool) types.Action {
if !endOfStream {
// Wait until we see the entire body to replace.
return types.ActionPause
}
originalBody, err := proxywasm.GetHttpResponseBody(0, bodySize)
if err != nil {
proxywasm.LogErrorf("failed to get response body: %v", err)
return types.ActionContinue
}
localReplay := false
/// Evaluate the content of the originalBody and set localReplay
if localReplay == true {
if err := proxywasm.SendHttpResponse(403, [][2]string{
{"powered-by", "proxy-wasm-go-sdk!!"}, {"content-type", "text/html"},
}, []byte(blcokedPageBody), -1); err != nil {
proxywasm.LogErrorf("failed to send local response: %v", err)
return types.ActionContinue
}
proxywasm.LogInfof("Blocked")
return types.ActionPause
}
return types.ActionContinue
}
Describe the bug / error
By the time I evaluate the response body in the filter, the envoy would already have completed streaming response headers. So upon proxywasm.SendHttpResponse envoy resets the connection with the below log. This is expected as per the documentation.
[2023-03-07 21:07:21.978][2341335][debug][http] [source/common/http/filter_manager.cc:936] [C0][S6738853039800735951] Resetting stream due to . Prior headers have already been sent
[2023-03-07 21:07:21.978][2341335][debug][http] [source/common/http/conn_manager_impl.cc:205] [C0][S6738853039800735951] doEndStream() resetting stream
Before evaluating the body, is there any way to delay sending response headers. I tried to see if I could achieve this by cascading two WASM filters, but no luck.
I think it's possible by cascading the native filter (using FilterHeadersStatus::StopIteration in encodeHeaders) and the WASM filter. Is there any way to achieve this without using the native filter?
What is your Envoy/Istio version?
1.25.2
What is the SDK version?
v0.20.0
What is your TinyGo version?
> tinygo version
tinygo version 0.27.0 darwin/amd64 (using go version go1.18.1 and LLVM version 15.0.0)
URL or snippet of your code including Envoy configuration
Additional context (Optional)
The text was updated successfully, but these errors were encountered:
at the point when executing OnHttpResponseBody, the headers have already been sent to the client, and that's the limitation due to the design of Proxy-Wasm. proxy-wasm/proxy-wasm-cpp-host#143
Based on the content of the response body, I want to either
HTTP/1.1 403 Forbidden
response by using proxywasm.SendHttpResponse.Describe the bug / error
By the time I evaluate the response body in the filter, the envoy would already have completed streaming response headers. So upon proxywasm.SendHttpResponse envoy resets the connection with the below log. This is expected as per the documentation.
Before evaluating the body, is there any way to delay sending response headers. I tried to see if I could achieve this by cascading two WASM filters, but no luck.
I think it's possible by cascading the native filter (using FilterHeadersStatus::StopIteration in encodeHeaders) and the WASM filter. Is there any way to achieve this without using the native filter?
What is your Envoy/Istio version?
1.25.2
What is the SDK version?
v0.20.0
What is your TinyGo version?
URL or snippet of your code including Envoy configuration
Additional context (Optional)
The text was updated successfully, but these errors were encountered: