I have a Django application which must have the following behavior: if a request has no
Content-Type header, it returns an error response.
In order to test this behavior, I need to make an HTTP request without a
I am using the
Client class in the
django.test module. This has many methods, including this one:
post(path, data=None, content_type=MULTIPART_CONTENT, follow=False, secure=False, **extra)
Makes a POST request on the provided path and returns a Response object, which is documented below.
If you provide content_type (e.g.
text/xmlfor an XML payload), the contents of data will be sent as-is in the POST request, using
content_typein the HTTP
If you don’t provide a value for
content_type, the values in data will be transmitted with a content type of
multipart/form-data. In this case, the key-value pairs in data will be encoded as a multipart message and used to create the POST data payload.
The documentation says that a
Content-Type header is always set on the request, irrespective of whether I pass a
So what other ways do I have to construct a request, such that it does not have a