]> git.proxmox.com Git - pve-apiclient.git/commitdiff
improve protocol selection heuristic
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 4 Dec 2020 11:18:45 +0000 (12:18 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 4 Dec 2020 11:18:45 +0000 (12:18 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/APIClient/LWP.pm

index bc158e96ca8e22bd7fdbdfcd86dd41524c9df7ed..63f2177615f896f20d645060b30505a9a8c4260f 100755 (executable)
@@ -353,7 +353,13 @@ sub new {
        $self->{port} = $self->{host} eq 'localhost' ? 85 : 8006;
     }
     if (!$self->{protocol}) {
        $self->{port} = $self->{host} eq 'localhost' ? 85 : 8006;
     }
     if (!$self->{protocol}) {
-       $self->{protocol} = $self->{host} eq 'localhost' ? 'http' : 'https';
+       # cope that PBS and PVE can be installed on the same host, and one may thus use
+       # 'localhost' then - so only default to http for privileged ports, in that case,
+       # as the HTTP daemons normally run with those (e.g., 85 or 87)
+       $self->{protocol} = $self->{host} eq 'localhost' && $self->{port} < 1024
+           ? 'http'
+           : 'https'
+           ;
     }
 
     $self->{useragent} = LWP::UserAgent->new(
     }
 
     $self->{useragent} = LWP::UserAgent->new(