add error message into http body

In our rust client, we can't access the http reason phrases[0], so let's
put them into the body itself if we don't specify an explicit content.

our proxmox-client code in rust already uses the body as message if
there is one [1], so we get that automatically.

0: https://github.com/hyperium/http/issues/737
1: https://git.proxmox.com/?p=proxmox.git;a=blob;f=proxmox-client/src/client.rs;h=9b078a9820405b22ca54c17ea4da4c586e0649b4;hb=refs/heads/master#l237

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2025-01-28 15:41:24 +01:00 committed by Thomas Lamprecht
parent f737984826
commit 9b59e1f033

View File

@ -389,6 +389,9 @@ sub error {
my ($self, $reqstate, $code, $msg, $hdr, $content) = @_;
eval {
$content //= $msg; # write error into body by default
# lack of content type here means either 'application/octet-stream' or the client
# can guess. This is fine since we don't know what content/msg actually contains.
my $resp = HTTP::Response->new($code, $msg, $hdr, $content);
$self->response($reqstate, $resp);
};