mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-21 07:56:03 +00:00
added sub GetFileFromURLQuiet() which does not show URL in logs
git-svn-id: https://svn.fhem.de/fhem/trunk@1800 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
5cec7be7df
commit
c041ca7286
@ -677,9 +677,9 @@ sub Calendar_GetUpdate($) {
|
|||||||
Log 4, "Calendar " . $hash->{NAME} . ": Updating...";
|
Log 4, "Calendar " . $hash->{NAME} . ": Updating...";
|
||||||
my $url= $hash->{fhem}{url};
|
my $url= $hash->{fhem}{url};
|
||||||
|
|
||||||
my $ics= GetFileFromURL($url);
|
my $ics= GetFileFromURLQuiet($url);
|
||||||
if(!defined($ics)) {
|
if(!defined($ics)) {
|
||||||
Log 1, "Calendar " . $hash->{NAME} . ": Could not retrieve $url";
|
Log 1, "Calendar " . $hash->{NAME} . ": Could not retrieve file at URL";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ sub Calendar_GetUpdate($) {
|
|||||||
|
|
||||||
my @entries= @{$ical->{entries}};
|
my @entries= @{$ical->{entries}};
|
||||||
if($#entries<0) {
|
if($#entries<0) {
|
||||||
Log 1, "Calendar " . $hash->{NAME} . ": Not an ical file at $url";
|
Log 1, "Calendar " . $hash->{NAME} . ": Not an ical file at URL";
|
||||||
$hash->{STATE}= "Not an ical file at URL";
|
$hash->{STATE}= "Not an ical file at URL";
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
@ -14,18 +14,18 @@ urlEncode($) {
|
|||||||
return $_;
|
return $_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# - if data (which is urlEncoded) is set, then a POST is performed, else a GET.
|
# - if data (which is urlEncoded) is set, then a POST is performed, else a GET.
|
||||||
# - noshutdown must be set for e.g the Fritz!Box
|
# - noshutdown must be set for e.g the Fritz!Box
|
||||||
sub
|
sub
|
||||||
GetFileFromURL($@)
|
CustomGetFileFromURL($$@)
|
||||||
{
|
{
|
||||||
my ($url, $timeout, $data, $noshutdown) = @_;
|
my ($quiet, $url, $timeout, $data, $noshutdown) = @_;
|
||||||
$timeout = 4.0 if(!defined($timeout));
|
$timeout = 4.0 if(!defined($timeout));
|
||||||
|
|
||||||
|
my $displayurl= $quiet ? "<hidden>" : $url;
|
||||||
if($url !~ /^(http|https):\/\/([^:\/]+)(:\d+)?(\/.*)$/) {
|
if($url !~ /^(http|https):\/\/([^:\/]+)(:\d+)?(\/.*)$/) {
|
||||||
Log 1, "GetFileFromURL $url: malformed or unsupported URL";
|
Log 1, "GetFileFromURL $displayurl: malformed or unsupported URL";
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,13 +82,29 @@ GetFileFromURL($@)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ret=~ s/(.*?)\r\n\r\n//s; # Not greedy: switch off the header.
|
$ret=~ s/(.*?)\r\n\r\n//s; # Not greedy: switch off the header.
|
||||||
Log 4, "GetFileFromURL: Got http://$host$path, length: ".length($ret);
|
my $hostpath= $quiet ? "<hidden>" : $host . $path;
|
||||||
|
Log 4, "GetFileFromURL: Got http://$hostpath, length: ".length($ret);
|
||||||
undef $conn;
|
undef $conn;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
##################
|
##################
|
||||||
# Compatibility mode
|
# Compatibility mode
|
||||||
|
|
||||||
|
sub
|
||||||
|
GetFileFromURL($@)
|
||||||
|
{
|
||||||
|
my ($url, @a)= @_;
|
||||||
|
return CustomGetFileFromURL(0, $url, @a);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub
|
||||||
|
GetFileFromURLQuiet($@)
|
||||||
|
{
|
||||||
|
my ($url, @a)= @_;
|
||||||
|
return CustomGetFileFromURL(1, $url, @a);
|
||||||
|
}
|
||||||
|
|
||||||
sub
|
sub
|
||||||
GetHttpFile($$)
|
GetHttpFile($$)
|
||||||
{
|
{
|
||||||
@ -96,4 +112,5 @@ GetHttpFile($$)
|
|||||||
return GetFileFromURL("http://$host$file");
|
return GetFileFromURL("http://$host$file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user