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 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, 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-develop...@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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM2HCJKbW%3D3dNkB7BDV4R6eSAGokg%3DPENFd%3D%2BhNwaTt9OQ%40mail.gmail.com.
I'm wondering though, if we should prefer this interface over the old one, as it's a bit more explicit in my view. I'd be happy to go through the docs and change the examples to using the headers attribute directly.
don't see a reason to deprecate it at all just now (though perhaps in _my_ ideal world that would happen at some point)
One further small addition, I think it would be good to be able to pass headers into the HttpResponse object
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAHoz%3DMa7QfRHgaT7iJTAqnpzVo6ZoHKcdLVp8dER%2BCus0G_wpw%40mail.gmail.com.
--
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-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/9a37d067-381f-46ab-bfc9-543d59a61c31o%40googlegroups.com.
@Tom looks great, should we add depreciation notices to the response.__gettitem__/del that way there are no 2 right ways to do things? I would probably keep it around until 3.2... I personally like the whole respose.headers it's much more readable.
--
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-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/86889efe-b876-46cc-8dc4-1559d6a6487do%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAHoz%3DMa7VDDSVj-5e1yF0RrCr0WKxujpN2-LwQc3NQNNT92V%3DQ%40mail.gmail.com.
I would prefer "one right way to do it", but I also don't see a compelling reason to deprecate the old interface.
The projects (ok, small sample) I've looked at are only now making this change. Folks will only change their code when they absolutely need to.
Could a warning in a of 'hey, did you know there is a new way to do this and btw the current way is going away' be more helpful. (I suspect not, but putting it out here).
--
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-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/98cba197-d079-4f7d-84e5-18308509a99ao%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAHoz%3DMaBbPUw7dcTeH2M-PmLgwUb4oaLsdQi%2Bz8hCVMpCgtbYQ%40mail.gmail.com.
On 16 Jul 2020, at 17:41, Nick Pope <nickpo...@gmail.com> wrote:I honestly thought the approach Carlton mentioned in https://github.com/django/django/pull/13186#discussion_r454956921 struck the correct balance and we could even, if desired, highlight in the release notes for the new `response.headers` that the old approach has not gone away such that developers do not need to rush to update their code. As highlighted by the examples above, it feels like there is precedent for that. Also if the data model approach is plumbed in to use `.headers` as in the proposed implementation, I don't see this as being a burden to maintain.Please let's be pragmatic about this stuff and not be driven to adhering to "one way to do it" as an extremist ideology rather than a laudable preference.
--
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-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/ED88B9B4-D474-4562-BFDB-4362B7168E56%40gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAHoz%3DMZP-CrA1DbKJa5Jp6tAFW-Mh3VRka5Cfy868dvcaQt8rw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/235A1B7D-59DB-4A67-977F-63DC04CB30FD%40gmail.com.