[pve-devel] [RFC PATCH http-server 2/2] use HTTP_INTERNAL_SERVER_ERROR were appropriate instead of '501'
Dominik Csapak
d.csapak at proxmox.com
Wed Jan 8 09:45:58 CET 2025
The http status code 501 is meant to be 'Not Implemented'[0] but that
clearly does not fit here as the default error when we encounter a
problem during handling an api request or upload.
So instead use '500' (HTTP_INTERNAL_SERVER_ERROR) which we already use
in other places where it fits.
0: https://datatracker.ietf.org/doc/html/rfc9110#name-501-not-implemented
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
src/PVE/APIServer/AnyEvent.pm | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
index bd76488..3b96d2a 100644
--- a/src/PVE/APIServer/AnyEvent.pm
+++ b/src/PVE/APIServer/AnyEvent.pm
@@ -504,7 +504,7 @@ sub send_file_start {
$self->response($reqstate, $resp, $mtime, $nocomp);
};
if (my $err = $@) {
- $self->error($reqstate, 501, $err);
+ $self->error($reqstate, HTTP_INTERNAL_SERVER_ERROR, $err);
}
};
@@ -1020,7 +1020,7 @@ sub handle_api2_request {
$self->response($reqstate, $resp, undef, $nocomp, $delay);
};
if (my $err = $@) {
- $self->error($reqstate, 501, $err);
+ $self->error($reqstate, HTTP_INTERNAL_SERVER_ERROR, $err);
}
}
@@ -1214,7 +1214,7 @@ sub handle_request {
die "no such file '$path'\n";
};
if (my $err = $@) {
- $self->error($reqstate, 501, $err);
+ $self->error($reqstate, HTTP_INTERNAL_SERVER_ERROR, $err);
}
}
@@ -1304,7 +1304,7 @@ sub file_upload_multipart {
};
if (my $err = $@) {
syslog('err', $err);
- $self->error($reqstate, 501, $err);
+ $self->error($reqstate, HTTP_INTERNAL_SERVER_ERROR, $err);
}
}
@@ -1402,10 +1402,10 @@ sub process_header {
my $te = $request->header('Transfer-Encoding');
if ($te && lc($te) eq 'chunked') {
# Handle chunked transfer encoding
- $self->error($reqstate, 501, "chunked transfer encoding not supported");
+ $self->error($reqstate, HTTP_INTERNAL_SERVER_ERROR, "chunked transfer encoding not supported");
return 0;
} elsif ($te) {
- $self->error($reqstate, 501, "Unknown transfer encoding '$te'");
+ $self->error($reqstate, HTTP_INTERNAL_SERVER_ERROR, "Unknown transfer encoding '$te'");
return 0;
}
@@ -1574,7 +1574,7 @@ sub authenticate_and_handle_request {
if ($len) {
if (!($method eq 'PUT' || $method eq 'POST')) {
- $self->error($reqstate, 501, "Unexpected content for method '$method'");
+ $self->error($reqstate, HTTP_INTERNAL_SERVER_ERROR, "Unexpected content for method '$method'");
return;
}
@@ -1624,7 +1624,7 @@ sub authenticate_and_handle_request {
}
if ($len > $limit_max_post) {
- $self->error($reqstate, 501, "for data too large");
+ $self->error($reqstate, HTTP_INTERNAL_SERVER_ERROR, "for data too large");
return;
}
--
2.39.5
More information about the pve-devel
mailing list