[pve-devel] [PATCH pve-http-server 1/1] anyevent: add rewrite_uri

Alexandre Derumier aderumier at odiso.com
Wed May 31 13:19:51 CEST 2023


allow to rewrite some uri, do nothing by default

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/APIServer/AnyEvent.pm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm
index b2ae99b..0be9b1f 100644
--- a/src/PVE/APIServer/AnyEvent.pm
+++ b/src/PVE/APIServer/AnyEvent.pm
@@ -1618,6 +1618,7 @@ sub push_request_header {
 
 		if ($line =~ /(\S+)\040(\S+)\040HTTP\/(\d+)\.(\d+)/o) {
 		    my ($method, $url, $maj, $min) = ($1, $2, $3, $4);
+		    $url = $self->rewrite_uri($url);
 
 		    if ($maj != 1) {
 			$self->error($reqstate, 506, "http protocol version $maj.$min not supported");
@@ -2072,6 +2073,12 @@ sub verify_spice_connect_url {
     #return ($vmid, $node, $port);
 }
 
+sub rewrite_uri {
+    my ($self, $uri) = @_;
+
+    return ($uri); #do nothing by default
+}
+
 # formatters can call this when the generate a new page
 sub generate_csrf_prevention_token {
     my ($username) = @_;
-- 
2.30.2





More information about the pve-devel mailing list