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 1 commit into from May 13, 2018


None yet
4 participants
Copy link

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:

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.


This comment has been minimized.

Copy link

commented May 13, 2018

@lepture lepture merged commit e378a8f into pallets:master May 13, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@ikonst ikonst deleted the ikonst:fix-204 branch May 13, 2018


This comment has been minimized.

Copy link

commented Oct 11, 2018

What version did this fix get released to?


This comment has been minimized.

Copy link
Contributor Author

commented Oct 30, 2018

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

@davidism davidism added this to the 0.15 milestone Dec 9, 2018

davidism added a commit that referenced this pull request Dec 10, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.