Opened 6 years ago

Closed 6 years ago

#15066 closed (duplicate)

GzipMiddleware does not work with generator-created responses

Reported by: Andreas Sommer <AndiDog@…> Owned by: nobody
Component: Uncategorized Version: master
Severity: Keywords: gzip
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


With a response like

def gen():
    yield "something"
return HttpResponse(gen())

and a HTTP 200 status code, the GzipMiddleware will always return an empty response because it accesses the response.content property twice. That means the _get_content getter applies ''.join twice to the generator, but a generator can only be iterated once.

See patch proposal.

Attachments (1)

gzip-generators.diff (975 bytes) - added by Andreas Sommer <AndiDog@…> 6 years ago.
Simple patch

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by Andreas Sommer <AndiDog@…>

Attachment: gzip-generators.diff added

Simple patch

comment:1 Changed 6 years ago by Russell Keith-Magee

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: duplicate
Status: newclosed

Duplicate of #7581.

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