anyevent: rpcenv is optional and from our child instance

This fixes the simple-demo, which was regressed with commit
8782148642 were we falsely assumed that
we always have an rpcenv instance here, but actually that's just
optional as it comes from our child class instance

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-05-22 08:07:17 +02:00
parent 3396e08126
commit e52d940029

View File

@ -1199,8 +1199,9 @@ sub unshift_read_header {
my $len = $r->header('Content-Length');
my $host_header = $r->header('Host');
my $rpcenv = $self->{rpcenv};
$rpcenv->set_request_host($host_header);
if (my $rpcenv = $self->{rpcenv}) {
$rpcenv->set_request_host($host_header);
}
# header processing complete - authenticate now
@ -1634,10 +1635,11 @@ sub new {
$self->can('generate_csrf_prevention_token');
# add default dirs which includes jquery and bootstrap
my $base = '/usr/share/libpve-http-server-perl';
add_dirs($self->{dirs}, '/css/' => "$base/css/");
add_dirs($self->{dirs}, '/js/' => "$base/js/");
add_dirs($self->{dirs}, '/fonts/' => "$base/fonts/");
my $jsbase = '/usr/share/javascript';
add_dirs($self->{dirs}, '/js/' => "$jsbase/");
# libjs-bootstrap uses symlinks for this, which we do not want to allow..
my $glyphicons = '/usr/share/fonts/truetype/glyphicons/';
add_dirs($self->{dirs}, '/js/bootstrap/fonts/' => "$glyphicons");
# init inotify
PVE::INotify::inotify_init();