Opened 18 years ago
Closed 17 years ago
#7046 closed (fixed)
ConditionalGetMiddleware doesn't set response code properly
| Reported by: | DOP | Owned by: | nobody |
|---|---|---|---|
| Component: | Core (Other) | Version: | dev |
| Severity: | 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
Just noticed that If-None-Match request doesn't really work even though ConditionalGetMiddleware is enabled and the response has ETag matching If-None-Match header in the request.
This is from django/middleware/http.py:
if response.has_header('ETag'):
if_none_match = request.META.get('HTTP_IF_NONE_MATCH', None)
if if_none_match == response['ETag']:
...
response.status = 304
if response.has_header('Last-Modified'):
if_modified_since = request.META.get('HTTP_IF_MODIFIED_SINCE', None)
if if_modified_since == response['Last-Modified']:
...
response.status = 304
Shouldn't it be response.status_code = 304?
Attachments (1)
Change History (4)
comment:1 by , 18 years ago
by , 17 years ago
comment:2 by , 17 years ago
| Has patch: | set |
|---|---|
| Triage Stage: | Unreviewed → Ready for checkin |
Yep, should be status_code. I think what's happened is that the Request/Response attribute is status_code, the parameter given to set it in __init__ is status, which has confused the person who added that code (it certainly confused me - I've opened #7453 to track this additional issue.
comment:3 by , 17 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
I have just checked it. Indeed it should be response.status_code = 304