pallets / flask

The Python micro framework for building web applications.

Home Page:https://flask.palletsprojects.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HTTP response status 204 (`No Content`) includes superfluous `Content-Type` header

ChrisHills463 opened this issue · comments

When returning HTTP code 204 Flask will include a Content-Type header which is superfluous as there is no content.

Environment:

  • Python version: 3.9
  • Flask version: 3.0.2

This is because Response has a default content type, and it's not worth inspecting the status and body on each response just in case its 204 with no body to remove the header. You can call del response.headers["content-type"] if you know you need to remove it.