Closed orangetangerine closed 3 years ago
No, you cannot update headers after modifying resposne body, since headers are already sent to the client.
However, you don't really need the Content-Length
header, and you can safely remove it before modifying the body.
Thanks!
Hi, I have a json response like
{"foo": "bar"}
. It's content-length is 14 I added a wasm to wrap the json response to sth like{"code": 0, "err": "", data: {"foo": "bar"}}
. It's content-length is 44. I tried callingaddResponseHeader("content-length", "44")
andreplaceResponseHeader("content-length", "44")
inonResponseBody. Neither worked. And curl complains:
curl: (18) transfer closed with 30 bytes remaining to read`.How can I update content-length after response body is modified? Thanks.