Skip to content

fix(http1.1): set content length 0 when body is empty - #1386

Open
joelwurtz wants to merge 1 commit into
HFQR:mainfrom
joelwurtz:fix/http1.1-none-body
Open

fix(http1.1): set content length 0 when body is empty#1386
joelwurtz wants to merge 1 commit into
HFQR:mainfrom
joelwurtz:fix/http1.1-none-body

Conversation

@joelwurtz

Copy link
Copy Markdown
Contributor

This force "Content-Length: 0" header when body is none (otherwise the client would consider this response as a Close Delimited body and would wait forever)

@fakeshadow

Copy link
Copy Markdown
Collaborator

The branch on extra status code check is good.

For adding content-lengh header we intentionally make the difference between "no body" and "empty sized body" so we keep the consistency across http/1, http/2, http/3.

In this case server should return with ResponseBody::body(Bytes::new()) or ResponseBody::bytes(Bytes::new()) rather than ResponseBody::empty()

The doc of Resonsebody::empty is wrong and cause this confusion due to refactor in rencent release. It shoud use be using the old ResponseBody::none as renference of doc

@fakeshadow

Copy link
Copy Markdown
Collaborator

#1390 would fix this issue. It works slightly different than previous comment as we cant break empty behavior with minor version bump so empty stays the same as doc comment stated and none method is added for the real no body use case

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.

2 participants