Opened 11 years ago

Closed 11 years ago

#20459 closed Cleanup/optimization (fixed)

Better example for setting header fields in documentation

Reported by: bbjay Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: bbjay Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I think the current example for setting header fields in HttpResponse objects is a bit unfortunate:
https://docs.djangoproject.com/en/dev/ref/request-response/#setting-header-fields

The Cache-Control field (also the Vary field) is a comma-separated multi value field.
e.g. Cache-Control: public, max-age=60
Setting its value by a dictionary access can unintentionally remove other present values, e.g. set by another middleware.

My proposed solution: change example to use 'Age' header field, mention and encourage use of patch_vary_header and patch_cache_control methods.
https://github.com/bbjay/django/commit/227f4bf4fe7971754ecc09aeb141b824a3f0550b

Change History (5)

comment:1 by Aymeric Augustin, 11 years ago

Triage Stage: UnreviewedAccepted

comment:2 by tadeck, 11 years ago

That fix looks nice. Would you care to create pull request etc., or should someone else do that?

comment:3 by bbjay, 11 years ago

Cool. Yes, i will gladly do that, just wanted to hear another opinion before filling a PR.
btw: do i need to set myself to cc to get updates for this ticket by email?

comment:4 by bbjay, 11 years ago

Cc: bbjay added
Has patch: set

comment:5 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In e83ff42792eb52235cacda58f3441673cc4e4c94:

Fixed #20459 - Improved example for setting HTTP header fields.

Thanks Jérémie Blaser.

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