diff --git a/pywb/framework/wsgi_wrappers.py b/pywb/framework/wsgi_wrappers.py index e4bbd1b2..569cf81a 100644 --- a/pywb/framework/wsgi_wrappers.py +++ b/pywb/framework/wsgi_wrappers.py @@ -86,7 +86,19 @@ class WSGIApp(object): error_view = self.wb_router.error_view if hasattr(exc, 'status'): - status = exc.status() + if callable(exc.status): + status = exc.status() + else: + status = exc.status + # wsgi requires status + # - to have at least 4 characters and + # - to start with a number / integer + if type(status) == int: + status = '{} Exception {}'.format(status, type(exc).__name__) + elif type(status) == str and status[0].isdigit(): + pass + else: + status = '500 Internal Server Error' else: status = '500 Internal Server Error' @@ -96,7 +108,7 @@ class WSGIApp(object): err_url = None if len(exc.args): - err_msg = exc.args[0] + err_msg = str(exc.args[0]) if print_trace: import traceback @@ -125,7 +137,7 @@ class WSGIApp(object): #msg = msg.encode('utf-8', 'ignore') return WbResponse.text_response(msg, - status=status) + status=status) #================================================================= DEFAULT_CONFIG_FILE = 'config.yaml' diff --git a/pywb/utils/test/test_loaders.py b/pywb/utils/test/test_loaders.py index 4b755726..dd5c3861 100644 --- a/pywb/utils/test/test_loaders.py +++ b/pywb/utils/test/test_loaders.py @@ -166,7 +166,7 @@ def seek_read_full(seekable_reader, offset): def test_s3_read_1(): pytest.importorskip('boto') - res = BlockLoader().load('s3://aws-publicdatasets/common-crawl/crawl-data/CC-MAIN-2015-11/segments/1424936462700.28/warc/CC-MAIN-20150226074102-00159-ip-10-28-5-156.ec2.internal.warc.gz', + res = BlockLoader().load('s3://commoncrawl/crawl-data/CC-MAIN-2015-11/segments/1424936462700.28/warc/CC-MAIN-20150226074102-00159-ip-10-28-5-156.ec2.internal.warc.gz', offset=53235662, length=2526)