1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #36456 -- Improved content type negotiation in technical 500 error response.

This commit is contained in:
IsJn-227
2025-06-13 15:52:46 +05:30
committed by Sarah Boyce
parent 449b9f9aee
commit be8c9b19ba
2 changed files with 19 additions and 2 deletions

View File

@@ -261,6 +261,22 @@ class DebugViewTests(SimpleTestCase):
status_code=500,
)
def test_technical_500_content_type_negotiation(self):
for accepts, content_type in [
("text/plain", "text/plain; charset=utf-8"),
("text/html", "text/html"),
("text/html,text/plain;q=0.9", "text/html"),
("text/plain,text/html;q=0.9", "text/plain; charset=utf-8"),
("text/*", "text/html"),
]:
with self.subTest(accepts=accepts):
with self.assertLogs("django.request", "ERROR"):
response = self.client.get(
"/raises500/", headers={"accept": accepts}
)
self.assertEqual(response.status_code, 500)
self.assertEqual(response["Content-Type"], content_type)
def test_classbased_technical_500(self):
with self.assertLogs("django.request", "ERROR"):
response = self.client.get("/classbased500/")