Don't set headers for responses with 1xx, 204 and 304 status code#1397
Don't set headers for responses with 1xx, 204 and 304 status code#1397
Conversation
|
Looking at this change and prompted by #1395 (comment), what happens if you still pass a body in, i.e. My skimming of the relevant ASGI 3 spec suggests the ASGI server may add Perhaps the implicit expectation is that the ASGI server will use "may" here and recognise response codes for which I apologise if I'm asking a question with an obvious/known answer already. I'm new to the ASGI ecosystem, and may be misunderstanding the division of responsibility or otherwise. |
Probably you've just got yourself an RFC-invalid response. We could potentially guard against those kinds of cases, and I'd be happy for us to discuss that as a follow-up issue if anyone's sufficiently motivated to do so. The most important thing for this pull request tho, is to make sure we're doing the right thing for the sensible cases. |
lovelydinosaur
left a comment
There was a problem hiding this comment.
Looks great, yup.
Observations prompted by the PR...
I think our naming of populate_content_length / populate_content_type in the init_headers method isn't really ideal at this point, and I'd also consider us switching it to a plain function rather than a stateful method (because I think it's easier to understand the behaviour then).
Not something to address here, but perhaps worth consideration.
Closes #1178 (?)
Closes #1282