Opened 9 years ago

Closed 8 years ago

#14020 closed New feature (fixed)

Make HttpResponse.get work like dict.get

Reported by: Michael Schurter Owned by: anonymous
Component: HTTP handling Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


>>> from django import http
>>> resp = http.HttpResponse()
>>> resp['Connection'] = 'close'
>>> resp.get('Connection')
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: get() takes exactly 3 arguments (2 given)
>>> foo = {}
>>> foo.get('Connection')

Attachments (2)

srsly.patch (506 bytes) - added by Michael Schurter 9 years ago.
14020_with_tests.patch (1.2 KB) - added by moopet 8 years ago.

Download all attachments as: .zip

Change History (8)

Changed 9 years ago by Michael Schurter

Attachment: srsly.patch added

comment:1 Changed 9 years ago by anonymous

Component: UncategorizedHTTP handling
Owner: changed from nobody to anonymous
Status: newassigned
Triage Stage: UnreviewedReady for checkin

comment:2 Changed 9 years ago by Alex Gaynor

Needs documentation: set
Needs tests: set
Triage Stage: Ready for checkinAccepted

comment:3 Changed 8 years ago by Julien Phalip

Severity: Normal
Type: New feature

Changed 8 years ago by moopet

Attachment: 14020_with_tests.patch added

comment:4 Changed 8 years ago by moopet

Easy pickings: unset
Needs tests: unset

comment:5 Changed 8 years ago by Victor van den Elzen <victor.van.den.elzen@…>

Needs documentation: unset
Triage Stage: AcceptedReady for checkin
UI/UX: unset

The docs say "To set or remove a header in your response, treat it like a dictionary". So I don't think this needs more documentation.

14020_with_tests.patch is obvious, has a test, applies cleanly to r16353 and passes all tests, so IMHO it's ready for checkin.

comment:6 Changed 8 years ago by Jannis Leidel

Resolution: fixed
Status: assignedclosed

In [16417]:

Fixed #14020 -- Made the HttpResponse class slightly more behave like a dictionary, allowing the alternative argument to be unset. Serious thanks to schmichael and moopet.

Note: See TracTickets for help on using tickets.
Back to Top