Opened 6 years ago

Closed 6 years ago

#15531 closed (fixed)

Changeset #15701 breaks response middleware that inspects content.

Reported by: Matthew Schinckel Owned by: nobody
Component: Generic views Version: 1.3-beta
Severity: Keywords: static middleware
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When serving a file, the new FileWrapper code is used. This uses an iterator to make the code less of a memory hog.

But it only allows for the response.content to be read once.

This is often not a problem, but I use some middleware that inspects the response.content, which means I have to alter the middleware so that it checks for a seek method on the response.content object, and go back to the start.

Is this an intended side effect? There is no mention of not being able to read from the response content in the middleware documentation.

Change History (5)

comment:1 Changed 6 years ago by Matthew Schinckel

r15701, I mean, not #...

comment:2 Changed 6 years ago by Matthew Schinckel

This breaks with some third-party apps: django-devserver, for instance.

comment:3 Changed 6 years ago by Luke Plant

Resolution: duplicate
Status: newclosed

This is essentially the same as #6027, #6527 and other bugs with iterators. HttpResponse is allowed to take iterators, and it is a known bug that this results in response.content only being available for reading once.

comment:4 Changed 6 years ago by Jannis Leidel

Resolution: duplicate
Status: closedreopened

I believe that's related to my change form yesterday, r15701. I'm going to revert it now that I actually see the big picture and reopen #15281.

comment:5 Changed 6 years ago by Jannis Leidel

Resolution: fixed
Status: reopenedclosed

In [15703]:

Fixed #15531 -- Partially reverted [15701] due to compatibility issues with middlewares that modify content of responses. Thanks for the report, schinckel. Refs #15281.

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