mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
wbresponse: always include Content-Length for text_response
This commit is contained in:
parent
eca3cf5fbf
commit
1464e89c41
@ -7,7 +7,10 @@ import random
|
|||||||
class CertificateAuthority(object):
|
class CertificateAuthority(object):
|
||||||
logger = logging.getLogger('pywb.CertificateAuthority')
|
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.ca_file = ca_file
|
||||||
self.certs_dir = certs_dir
|
self.certs_dir = certs_dir
|
||||||
|
|
||||||
@ -31,7 +34,7 @@ class CertificateAuthority(object):
|
|||||||
self.cert.set_version(3)
|
self.cert.set_version(3)
|
||||||
# avoid sec_error_reused_issuer_and_serial
|
# avoid sec_error_reused_issuer_and_serial
|
||||||
self.cert.set_serial_number(random.randint(0,2**64-1))
|
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_notBefore(0) # now
|
||||||
self.cert.gmtime_adj_notAfter(100*365*24*60*60) # 100 yrs in future
|
self.cert.gmtime_adj_notAfter(100*365*24*60*60) # 100 yrs in future
|
||||||
self.cert.set_issuer(self.cert.get_subject())
|
self.cert.set_issuer(self.cert.get_subject())
|
||||||
|
@ -161,7 +161,8 @@ class WbResponse(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def text_response(text, status='200 OK', content_type='text/plain'):
|
def text_response(text, status='200 OK', content_type='text/plain'):
|
||||||
status_headers = StatusAndHeaders(status,
|
status_headers = StatusAndHeaders(status,
|
||||||
[('Content-Type', content_type)])
|
[('Content-Type', content_type),
|
||||||
|
('Content-Length', str(len(text)))])
|
||||||
|
|
||||||
return WbResponse(status_headers, value=[text])
|
return WbResponse(status_headers, value=[text])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user