public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH http-server v2 2/2] use HTTP_INTERNAL_SERVER_ERROR were appropriate instead of '501'
Date: Tue, 28 Jan 2025 15:41:25 +0100	[thread overview]
Message-ID: <20250128144125.3589111-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250128144125.3589111-1-d.csapak@proxmox.com>

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@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	other threads:[~2025-01-28 14:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-28 14:41 [pve-devel] [PATCH http-server v2 1/2] add error message into http body Dominik Csapak
2025-01-28 14:41 ` Dominik Csapak [this message]
2025-01-28 14:52 ` [pve-devel] applied-series: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250128144125.3589111-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal