Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FrontendApp: forward HTTP status of CDX backend #624

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pywb/apps/frontendapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,12 @@ def serve_cdx(self, environ, coll='$root'):
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')
Expand Down
5 changes: 4 additions & 1 deletion pywb/warcserver/basewarcserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def send_error(self, errs, start_response,
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