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:
parent
1bb7aa01ce
commit
a6a186891e
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user