﻿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
2504	ConditionalGetMiddleware causes Content-Length to be 0 on HttpResponse with fileobject	django@…	Aymeric Augustin	"middleware/http.py:

{{{
        if not response.has_header('Content-Length'):
            response['Content-Length'] = str(len(response.content))
}}}

If response is build with a file object, str(len(response.content)) is 0, and the browser will ignore the page, if the handler does not set content-length.

If response.content is not a string, do not add Content-Length.
Optional we could implement:
If response.content is a file like object, and content.name is a valid filename, we could get the size with os.path.getsize and those.
"	Bug	closed	Core (Other)	dev	Normal	duplicate		hv@… kmike84@…	Accepted	1	0	0	1	0	0
