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

Throw with simple error for curl user-agent #198

Closed
GregBrimble opened this issue Mar 2, 2022 · 2 comments · Fixed by #210
Closed

Throw with simple error for curl user-agent #198

GregBrimble opened this issue Mar 2, 2022 · 2 comments · Fixed by #210
Labels
enhancement New feature or request
Milestone

Comments

@GregBrimble
Copy link
Member

GregBrimble commented Mar 2, 2022

The Youch error page is returned to cURL.

curl http://127.0.0.1:8788/page-that-errors
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title> </title>
...

There's already logic to only return a pretty-error page when the request Accept header includes text/html. cURL sends Accept: */*.

Would you consider extending that check to include if the user-agent contains curl/, and if so, also return the simple page?

const accept = req.headers.accept?.toLowerCase() ?? "";
if (
accept.includes("text/html") ||
accept.includes("*/*") ||
accept.includes("text/*")
) {
// Send pretty HTML error page if client accepts it

@mrbbot
Copy link
Contributor

mrbbot commented Mar 4, 2022

Hey! 👋 Thanks for raising this. Sounds like a good idea. 🙂

@mrbbot mrbbot added the enhancement New feature or request label Mar 4, 2022
@mrbbot mrbbot added this to the 2.4.0 milestone Mar 8, 2022
@mrbbot
Copy link
Contributor

mrbbot commented Apr 2, 2022

Hey! 👋 I've just released version 2.4.0 including this. You can find the full changelog here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants