﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6027	FileWrapper iterator drained by GzipMiddleware before content can be returned	volsung@…	nobody	"Using FileWrapper to return content in an HttpResponse object works fine, unless you have GzipMiddleware active.  This combination will try to iterate through the FileWrapper object several times, but the iterator will return nothing after the first pass, and the HTTP response received by the client will be empty.

The problem is fixed if you modify `FileWrapper.__iter__()` to return a new FileWrapper, rewound to the beginning of the file.  (At the moment, `FileWrapper.__iter__()` returns self, so the current position in the file is not changed.)  Unfortunately, this fix cannot be used in general, since not all file-like objects support seeking.  Also, I don't know what the correct Python iterator protocol is when `__iter__()` is called on an existing iterator object.  Is it supposed to return a new iterator, reset to the start of the sequence, or an iterator at the current position? (I am assuming the latter...)




"	Bug	closed	Core (Other)	dev	Normal	duplicate		Forest Bond Oliver Beattie daemianmack@… net147	Accepted	0	0	0	0	0	0
