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

Conversation

sebastian-nagel
Copy link
Contributor

Description

The patch makes FrontendApp forward the HTTP status of the CDX backend, so that clients can handle errors properly.

Motivation and Context

If the CDX backend fails to process a query, the FrontendApp still responds with HTTP status 200 OK. The (error) status (eg. "400 Bad request", "404 Not found", etc.) should be passed forward to the client.

A clear HTTP error simplifies the processing of the CDX results in the client. The fix also ensures that the CDXJ API is compatibility with the behavior of the API in PyWB 0.33.2.

One example to reproduce the issue:

  • call the CDXJ API with an unsupported output format (...&output=foo)
  • the FrontendApp responds with HTTP status 200. Only the response body indicates that there was actually an error and shows the reason {"message": "output=foo not supported"}

With the patch applied the response status will be 400 Bad Request output=foo not supported, the response body is unchanged.

Types of changes

  • Replay fix (fixes a replay specific issue)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added or updated tests to cover my changes.
  • All new and previously successful tests passed.

- 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/...
@ikreymer ikreymer merged commit 13ea5ba into webrecorder:master Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants