Fix basic auth. TUrn ControlAddress into a URI if it isn't one

This commit is contained in:
Isaac Connor 2020-01-12 18:07:20 -05:00
parent 8dfe7460f3
commit f6d10e84f2
1 changed files with 5 additions and 1 deletions

View File

@ -51,8 +51,12 @@ sub open {
my $self = shift; my $self = shift;
$self->loadMonitor(); $self->loadMonitor();
if ( $self->{Monitor}->{ControlAddress} !~ /^\w+:\/\// ) {
# Has no scheme at the beginning, so won't parse as a URI
$self->{Monitor}->{ControlAddress} = 'http://'.$self->{Monitor}->{ControlAddress};
}
my $uri = URI->new($self->{Monitor}->{ControlAddress}); my $uri = URI->new($self->{Monitor}->{ControlAddress});
$ADDRESS = $uri->scheme.'://'.$uri->host().$uri->path().($uri->port()?':'.$uri->port():''); $ADDRESS = $uri->scheme.'://'.$uri->authority().$uri->path().($uri->port()?':'.$uri->port():'');
use LWP::UserAgent; use LWP::UserAgent;
$self->{ua} = LWP::UserAgent->new; $self->{ua} = LWP::UserAgent->new;