I don't find myself using HttpResponse very often, usually I'm using DRF's
Responses. But today I needed to use one, and as I was writing tests, I
ended up somewhat astonished, so with the principle of least astonishment
in mind... I had anticipated that I could check the headers with
`response.headers`, similar to how the new request.headers
<https://code.djangoproject.com/ticket/20147> works, but apparently this is
not the case. After reading the docs, I found out that I should just treat
the HttpResponse object itself as if it were a dictionary of headers. This
seems very strange to me, it's not what I expect, but maybe I'm in the
minority.

I have no interest in deprecating the old API, but it would be nice if the
headers were all accessible from a simple headers dict, and perhaps make
this the source of truth, allowing access with any casing but preserving
the original casing for output. It looks like what is currently
HttpResponse._headers was once HttpRequest.headers, but this was 13 years
ago <https://code.djangoproject.com/ticket/5479>, I don't think it'd be
confusing to add the property back as something different.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAHoz%3DMa9-m%2Bfqj0wqzQ7qW5Aiw3POHtNOp2NTBaHeP_ux5FhLg%40mail.gmail.com.

Reply via email to