tetratelabs / proxy-wasm-go-sdk

WebAssembly for Proxies (Go SDK)
Apache License 2.0
689 stars 152 forks source link

example: adds http_body_chunk #421

Closed M4tteoP closed 10 months ago

M4tteoP commented 10 months ago

The PR provides an example of retrieving the request body chunk by chunk. Requires https://github.com/tetratelabs/proxy-wasm-go-sdk/pull/418, I will remove the draft status and rebase once (and if) #418 gets merged.

The http_body_chunk test provides logs to get a better understanding of how the body callbacks are behaving:

OnHttpRequestBody called. BodySize: 9, totalRequestBodyReadSize: 0, endOfStream: false
read chunk size: 9, chunk: chunk1...
OnHttpRequestBody called. BodySize: 18, totalRequestBodyReadSize: 9, endOfStream: false
read chunk size: 9, chunk: chunk2...
OnHttpRequestBody called. BodySize: 27, totalRequestBodyReadSize: 18, endOfStream: false
read chunk size: 9, chunk: chunk3...
OnHttpRequestBody called. BodySize: 50, totalRequestBodyReadSize: 27, endOfStream: false
read chunk size: 23, chunk: chunk4 with pattern ...
pattern found in chunk: 4
local 403 response sent