Closed Xunzhuo closed 3 years ago
@PiotrSikora @mathetake This problem confused me, please check this when u are free.
@Xunzhuo you're replacing request body, possibly mutliple times (OnRequestBody
is called for each request body chunk), but you don't modify the headers that include Content-Length
header, so the updated body doesn't match expected length, hence 400 Bad Request
.
If you want to replace complete body, you need to remove Content-Length
header (or replace it if you know the correct value ahead of time), and then you can either wait until end_of_stream
is true
, or simply replace request body the first callback, and discard future chunks in subsequent calls, but you need to code that in your plugin, since that's not something that works out of the box right now.
@PiotrSikora Thanks, problems have been solved by your guide😊
@PiotrSikora Thanks, problems have been solved by your guide😊
How do u change the Content-Length header in onRequestBody(), according to WASM doc, it can't modify HTTP header in onRequestBody(). Would you share your code? thanks Cliff
When I try to change request body, I got 400 response occasionally. Sometimes envoy respond in expectation and sometimes respond in 400 Bad request
I use
curl -d "Hello,World" localhost:18000/
to send requestEnvoy log is below:
wasm c++ code:
envoy config is:
upstream is coded by Golang http package:
Expected response from upstream is:
Sometimes it return: