Django

Code

Ticket #7046 (closed: fixed)

Opened 5 months ago

Last modified 2 months ago

ConditionalGetMiddleware doesn't set response code properly

Reported by: DOP Assigned to: nobody
Milestone: Component: Core framework
Version: SVN Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

7046.diff (0.9 kB) - added by Simon Greenhill on 06/14/08 07:38:49.

Change History

04/24/08 05:08:16 changed by Eratothene

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

I have just checked it. Indeed it should be response.status_code = 304

06/14/08 07:38:49 changed by Simon Greenhill

  • attachment 7046.diff added.

06/14/08 07:44:25 changed by Simon Greenhill

  • has_patch set to 1.
  • stage changed from Unreviewed to 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.

06/30/08 02:03:59 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [7793]) Fixed #7046 -- set the response status code correctly in ConditionalGetMiddleware?.


Add/Change #7046 (ConditionalGetMiddleware doesn't set response code properly)




Change Properties
Action