﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37445	Invalid Content-Type header (still) returns HTTP 500 instead of 400	Oliver Haas	Oliver Haas	"#36991 made `HttpRequest._set_content_type_params()` raise `BadRequest` for an invalid `Content-Type` header; before it was `LookupError`. 

**But** according to the [https://docs.djangoproject.com/en/dev/ref/exceptions/#django.core.exceptions.BadRequest docs], the behavior and intention of the change was to my understanding to get a 400 response, but current main still responds with a 500, e.g. just with

{{{
curl -i -X POST http://127.0.0.1:8000/ -H ""Content-Type: text/plain; charset*=BOGUS''%20""
}}}

This isn't really a regression, more like an incomplete fix.

Basically the exceptions are raised when the request is created and not inside the `get_response()`, so it slips by before the aptly named `convert_exception_to_response()` is used. 

I'm intending to open a pull request shortly after this.


'Disclaimer'
I used Claude Code to investigate this bug. I saw this (super rare) error in our production env, probably coming from a security scanner. Mostly harmless, but also thought I could contribute here with a quick fix."	Bug	assigned	HTTP handling	6.1	Normal				Unreviewed	0	0	0	0	1	0
