Skip to content

No convenient way to send a custom error message #19

@edgar-bonet

Description

@edgar-bonet

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions