mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
FrontendApp: forward HTTP status of CDX backend (#624)
* FrontendApp: forward HTTP status of CDX backend to allow clients to handle errors more easily * WarcServer: keep the HTTP status lines short - append the exception message only if the status isn't a string (WbException and inherited classes already have nice status string) - avoid overlong status lines, eg. HTTP/1.1 404 Not Found No Captures found for: https://very-long.url/...
This commit is contained in:
parent
c62b1bc987
commit
13ea5baee5
@ -404,10 +404,12 @@ class FrontEndApp(object):
|
||||
try:
|
||||
res = requests.get(cdx_url, stream=True)
|
||||
|
||||
status_line = '{} {}'.format(res.status_code, res.reason)
|
||||
content_type = res.headers.get('Content-Type')
|
||||
|
||||
return WbResponse.bin_stream(StreamIter(res.raw),
|
||||
content_type=content_type)
|
||||
content_type=content_type,
|
||||
status=status_line)
|
||||
|
||||
except Exception as e:
|
||||
return WbResponse.text_response('Error: ' + str(e), status='400 Bad Request')
|
||||
|
@ -141,6 +141,9 @@ class BaseWarcServer(object):
|
||||
out_headers['ResErrors'] = res[0]
|
||||
message = message.encode('utf-8')
|
||||
|
||||
message = str(status) + ' ' + message
|
||||
if isinstance(status, str):
|
||||
message = status
|
||||
else:
|
||||
message = str(status) + ' ' + message
|
||||
start_response(message, list(out_headers.items()))
|
||||
return res
|
||||
|
Loading…
x
Reference in New Issue
Block a user