Skip to content

http server: don't automatically add a content-length header#137

Open
pchickey wants to merge 1 commit into
mainfrom
pch/no_implicit_content_length
Open

http server: don't automatically add a content-length header#137
pchickey wants to merge 1 commit into
mainfrom
pch/no_implicit_content_length

Conversation

@pchickey

Copy link
Copy Markdown
Contributor

This behavior might not work on some wasi-http runtimes, since restricted headers are not specified.

In particular, content-length is a header that is http1 specific - in http2 and 3 framing is handled differently. But even in http1, its making a decision about framing that the imported http implementation may not agree with, e.g. there could be an implementation that insists on always sending chunked transfer encoding, and by setting content-length all the time it means that either wstd will always unwrap on a forbidden error here, or the implementation has to silently filter out that header. Neither of those alternatives serve wstd's users well.

This behavior might not work on some wasi-http runtimes, since
restricted headers are not specified.

In particular, content-length is a header that is http1 specific - in
http2 and 3 framing is handled differently. But even in http1, its
making a decision about framing that the imported http implementation
may not agree with, e.g. there could be an implementation that insists
on always sending chunked transfer encoding, and by setting
content-length all the time it means that either wstd will always unwrap
on a `forbidden` error here, or the implementation has to silently
filter out that header. Neither of those alternatives serve wstd's users
well.
@pchickey
pchickey requested a review from yoshuawuyts July 21, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant