#33230: Test client doesn't set explicitly provided Content-Type when data is
empty
-------------------------------------+-------------------------------------
Reporter: Markus Holtermann | Owner: Anders
Type: | Kaseorg
Cleanup/optimization | Status: closed
Component: Testing framework | Version: 3.2
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):
* status: assigned => closed
* resolution: => wontfix
Comment:
Hello Anders, thank you for providing additional details.
I've gone through all the links, and for a while, I found myself diving
into some non-trivial rabbit holes. However, it was a fun exercise to read
and investigate this issue. I believe we are in agreement that the HTTP
spec (RFC 9110) does not require a `Content-Type` header for empty bodies.
Having said that, I truly appreciate how request validation against an
OpenAPI spec benefits from always having a `Content-Type` header for map
indexing. However, if I were implementing a web service that does this, I
would make it robust enough to handle requests without this header,
considering that the HTTP spec does not enforce its presence. This could
involve checking the `Content-Length` first or using another strategy that
aligns with the specific business logic of the API endpoint.
The key point here is that, even if we were to change how the Django test
client behaves, a robust web service should still be able to handle cases
where the `Content-Type` is missing. After all, there might be other real
clients out there that do not send it for requests with empty bodies.
Following that rationale, I think that this is still a `wontfix`. If you
disagree, the recommended path forward is to first propose and discuss the
issue with the community and gain consensus to pursue the proposed change.
To do that, please start a new conversation on the
[https://forum.djangoproject.com/c/internals/5 Django Forum], where you'll
reach a wider audience and likely get extra feedback.
Cheers, Natalia.
--
Ticket URL: <https://code.djangoproject.com/ticket/33230#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018b6cda1e3e-c06fd84e-c889-4a3c-900d-a5cd047619eb-000000%40eu-central-1.amazonses.com.