Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never send Content-Length for 204 #1294

Merged
merged 1 commit into from May 13, 2018
Merged

Never send Content-Length for 204 #1294

merged 1 commit into from May 13, 2018

Conversation

@ikonst
Copy link
Contributor

@ikonst ikonst commented May 13, 2018

With flask-restful, it's easy to make a malformed response by doing return '', 204 or return None, 204. It might be idiomatic, but it would result in a 204 response with a non-empty body (containing a JSON payload such as '' or null).

We used to reset the Content-Length to 0 for status code 204, but since 1c70c3e we keep Content-Length: N while the body is eliminated (see BaseResponse.get_app_iter). This broke existing flask-restful applications:
flask-restful/flask-restful#736

Per section 3.3.2 of RFC 7230, "a server MUST NOT send a Content-Length header field in any response with a status code of 1xx (Informational) or 204 (No Content)". This change enforces it in get_wsgi_headers.

@lepture
Copy link
Member

@lepture lepture commented May 13, 2018

@lepture lepture merged commit e378a8f into pallets:master May 13, 2018
1 check passed
@ikonst ikonst deleted the fix-204 branch May 13, 2018
@randyesq
Copy link

@randyesq randyesq commented Oct 11, 2018

What version did this fix get released to?

@ikonst
Copy link
Contributor Author

@ikonst ikonst commented Oct 30, 2018

@randyesq still waiting for this to be released. The relevant issue has been locked by the project maintainer:
#1296

@davidism davidism added this to the 0.15 milestone Dec 9, 2018
davidism added a commit that referenced this issue Dec 10, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants