﻿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
33230	Test client doesn't set explicitly provided Content-Type when data is empty	Markus Holtermann	Anders Kaseorg	"When using Django's test client and setting an explicit Content-Type but have an empty data, the provided content type isn't available in the request in the view:


{{{#!python
from django.views.decorators.csrf import csrf_exempt
from django.http.response import HttpResponse


@csrf_exempt
def test_view(request):
    return HttpResponse(repr(request.headers))


class MyTest(SimpleTestCase):
    def test_content_type(self):
        resp = self.client.post(""/"", data=b"""", content_type=""application/octet-stream"")
        print(resp.content)
        # b""{'Cookie': ''}""
}}}

Frankly, I'm not sure if that's the intended behavior. Can one set a Content-Type for a request without payload? The Python Requests library allows for it and sets the header.

The code in question that only conditionally sets the Content-Type is https://github.com/django/django/blob/afeafd6036616bac8263d762c1610f22241c0187/django/test/client.py#L461-L466"	Cleanup/optimization	closed	Testing framework	3.2	Normal	wontfix		Aymeric Augustin	Unreviewed	1	0	0	0	0	0
