libuhttpd
libuhttpd copied to clipboard
No convenient way to send a custom error message
Prior to commit e5577217fc3e79978a22b925842794a447c36ed7, 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?