wasi-http icon indicating copy to clipboard operation
wasi-http copied to clipboard

Clarification regarding host behaviour with `Content-Length` header

Open karthik2804 opened this issue 1 year ago • 1 comments

What is the expected/acceptable behavior in the host in terms of automatically setting the Content-Length header on behalf of the guest when the size of the body is known?

karthik2804 avatar Mar 01 '24 14:03 karthik2804

Good question, b/c I know this varies widely. The expectation, iiuc, is that the host never sets Content-Length automatically, and thus it's up to the guest (or more likely: the guest's HTTP standard library) to set Content-Length appropriately (e.g., the JS Request constructor would set Content-Length when given a Blob, but not when given a ReadableStream). Supporting this: there's not even really a general way for a WASI host to know the body length up front (given the design of streams and the lack of any sort of length-specified-up-front-stream.

lukewagner avatar Mar 01 '24 19:03 lukewagner