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

No convenient way to send a custom error message #19

Open
edgar-bonet opened this issue Feb 5, 2022 · 0 comments
Open

No convenient way to send a custom error message #19

edgar-bonet opened this issue Feb 5, 2022 · 0 comments

Comments

@edgar-bonet
Copy link
Contributor

Prior to commit e557721, it was easy to send a custom error message to the client:

conn->error(conn, HTTP_STATUS_BAD_REQUEST, "I cannot understand this POST data.\n");

would give:

$ curl localhost:8000 -d zborglh
I cannot understand this POST data.

Since that commit, the error() method is no longer available. Instead, we have a new method called send_error(), which always sends an empty body:

conn->send_error(conn, HTTP_STATUS_BAD_REQUEST, "I cannot understand this POST data.");

gives:

$ curl localhost:8000 -d zborglh
$     # ← empty response body

Inspecting the full response, it appears the custom message is sent, but it is sent as the status text:

$ curl -i localhost:8000 -d zborglh
HTTP/1.1 400 I cannot understand this POST data.
Server: Libuhttpd/3.14.1
Content-Length: 0
Content-Type: text/plain
Connection: close

A custom status text is far less useful than a custom message within the response body. Would you please consider restoring the functionality of the previous error() method?

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

No branches or pull requests

1 participant