Code

Opened 3 years ago

Closed 3 years ago

#15531 closed (fixed)

Changeset #15701 breaks response middleware that inspects content.

Reported by: 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.

Attachments (0)

Change History (5)

comment:1 Changed 3 years ago by schinckel

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

r15701, I mean, not #...

comment:2 Changed 3 years ago by schinckel

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

comment:3 Changed 3 years ago by lukeplant

  • Resolution set to duplicate
  • Status changed from new to closed

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 3 years ago by jezdez

  • Resolution duplicate deleted
  • Status changed from closed to reopened

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 3 years ago by jezdez

  • Resolution set to fixed
  • Status changed from reopened to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.