Wrong content-length in wsgi_application on Python 3
Bug #1050638 reported by
Piotr Szymankiewicz
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ladon |
New
|
Undecided
|
Unassigned |
Bug Description
At the end of wsgi_application.py
content_length = str(len(output))
is performed before encoding
if sys.version_
# Python 3 support
if type(output)==str:
output = bytes(output,
When output contains non-ascii characters 'Content-Length' is wrong.
To post a comment you must log in.
never late to fix some good oldies
just reorder end lines and move python version checker before response headers
if sys.version_ info[0] >=3: charset)
# Python 3 support
if type(output)==str:
output = bytes(output,
content_length = str(len(output))
response_headers += [ type,charset) ), Length' , content_length) response( status, response_headers)
('Content-Type', "%s; charset=%s" % (content_
('Content-
]
start_
if hasattr( output, 'read') : 'wsgi.file_ wrapper' ](output, block_size) read(block_ size), '')
# File-like object
block_size = 4096
if 'wsgi.file_wrapper' in environ:
return environ[
else:
return iter(lambda: output.
return [output]