Opened 14 years ago

Closed 13 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: dev
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

Description

>>> 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 14 years ago.
14020_with_tests.patch (1.2 KB ) - added by moopet 13 years ago.

Download all attachments as: .zip

Change History (8)

by Michael Schurter, 14 years ago

Attachment: srsly.patch added

comment:1 by anonymous, 14 years ago

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

comment:2 by Alex Gaynor, 13 years ago

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

comment:3 by Julien Phalip, 13 years ago

Severity: Normal
Type: New feature

by moopet, 13 years ago

Attachment: 14020_with_tests.patch added

comment:4 by moopet, 13 years ago

Easy pickings: unset
Needs tests: unset

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

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 by Jannis Leidel, 13 years ago

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