Change detect_realm to return empty string instead o f undef. Just so that realm is always a string and not undefined. Fix integer comparison on strings and make detect_realm succeed as long as response isn't 401.

pull/3750/head
Isaac Connor 2023-07-24 12:42:20 -04:00
parent add08aeb56
commit 0134f8e447
1 changed files with 4 additions and 4 deletions

View File

@ -83,7 +83,7 @@ sub open {
# Detect REALM
$REALM = $self->detect_realm($PROTOCOL, $ADDRESS, $REALM, $USERNAME, $PASSWORD, '/cgi/ptdc.cgi');
if (defined($REALM)) {
if ($REALM) {
$self->{state} = 'open';
return !undef;
}
@ -118,7 +118,7 @@ sub detect_realm {
Debug("Changing REALM to $realm");
$self->{ua}->credentials($address, $realm, $username, $password);
$res = $self->{ua}->get($protocol.$address.$url);
if ($res->is_success()) {
if ($res->status_line() ne '401 Unauthorized') {
return $realm;
}
Error('Authentication still failed after updating REALM' . $res->status_line);
@ -135,7 +135,7 @@ sub detect_realm {
} else {
Debug('No headers line');
} # end if headers
return undef;
return '';
}
sub sendCmd {
@ -425,7 +425,7 @@ sub reset {
sub reboot {
my $self = shift;
Debug('Camera Reboot');
if ($$self{state} != 'open') {
if ($$self{state} ne 'open') {
Warning("Not open. opening. Should call ->open() before calling reboot()");
return if !$self->open();
}