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

wbresponse: always include Content-Length for text_response

This commit is contained in:
Ilya Kreymer 2014-07-26 14:24:28 -07:00
parent eca3cf5fbf
commit 1464e89c41
2 changed files with 7 additions and 3 deletions

View File

@ -7,7 +7,10 @@ import random
class CertificateAuthority(object):
logger = logging.getLogger('pywb.CertificateAuthority')
def __init__(self, ca_file='pywb-ca.pem', certs_dir='./pywb-ca'):
def __init__(self, ca_file='pywb-ca.pem',
certs_dir='./pywb-ca',
certname='pywb CA'):
self.ca_file = ca_file
self.certs_dir = certs_dir
@ -31,7 +34,7 @@ class CertificateAuthority(object):
self.cert.set_version(3)
# avoid sec_error_reused_issuer_and_serial
self.cert.set_serial_number(random.randint(0,2**64-1))
self.cert.get_subject().CN = 'pywb CA on {}'.format('')
self.cert.get_subject().CN = certname
self.cert.gmtime_adj_notBefore(0) # now
self.cert.gmtime_adj_notAfter(100*365*24*60*60) # 100 yrs in future
self.cert.set_issuer(self.cert.get_subject())

View File

@ -161,7 +161,8 @@ class WbResponse(object):
@staticmethod
def text_response(text, status='200 OK', content_type='text/plain'):
status_headers = StatusAndHeaders(status,
[('Content-Type', content_type)])
[('Content-Type', content_type),
('Content-Length', str(len(text)))])
return WbResponse(status_headers, value=[text])