1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

wbrequestresponse: text response: calculate Content-Length from encoded utf-8 bytes, not the original text

This commit is contained in:
Ilya Kreymer 2016-09-20 15:41:25 -07:00
parent 1bb7aa01ce
commit a6a186891e

View File

@ -239,11 +239,12 @@ class WbResponse(object):
@staticmethod
def text_response(text, status='200 OK', content_type='text/plain; charset=utf-8'):
encoded_text = text.encode('utf-8')
status_headers = StatusAndHeaders(status,
[('Content-Type', content_type),
('Content-Length', str(len(text)))])
('Content-Length', str(len(encoded_text)))])
return WbResponse(status_headers, value=[text.encode('utf-8')])
return WbResponse(status_headers, value=[encoded_text])
@staticmethod
def redir_response(location, status='302 Redirect', headers=None):