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.csa...@proxmox.com>
---
changes from rfc:
* only change the code where it actually make sense, the other instances
  were cases of us not implementing part of the request so 501 there
  was ok in the first place

 src/PVE/APIServer/AnyEvent.pm | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
index 9a1e35a..469dd28 100644
--- a/src/PVE/APIServer/AnyEvent.pm
+++ b/src/PVE/APIServer/AnyEvent.pm
@@ -507,7 +507,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);
        }
     };
 
@@ -1023,7 +1023,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);
     }
 }
 
@@ -1217,7 +1217,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);
     }
 }
 
@@ -1307,7 +1307,7 @@ sub file_upload_multipart {
     };
     if (my $err = $@) {
        syslog('err', $err);
-       $self->error($reqstate, 501, $err);
+       $self->error($reqstate, HTTP_INTERNAL_SERVER_ERROR, $err);
     }
 }
 
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to