mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-08 13:24:56 +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...";
|
||||
my $url= $hash->{fhem}{url};
|
||||
|
||||
my $ics= GetFileFromURL($url);
|
||||
my $ics= GetFileFromURLQuiet($url);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -691,7 +691,7 @@ sub Calendar_GetUpdate($) {
|
||||
|
||||
my @entries= @{$ical->{entries}};
|
||||
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";
|
||||
return 0;
|
||||
};
|
||||
|
@ -14,18 +14,18 @@ urlEncode($) {
|
||||
return $_;
|
||||
}
|
||||
|
||||
|
||||
##################
|
||||
# - 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
|
||||
sub
|
||||
GetFileFromURL($@)
|
||||
CustomGetFileFromURL($$@)
|
||||
{
|
||||
my ($url, $timeout, $data, $noshutdown) = @_;
|
||||
my ($quiet, $url, $timeout, $data, $noshutdown) = @_;
|
||||
$timeout = 4.0 if(!defined($timeout));
|
||||
|
||||
my $displayurl= $quiet ? "<hidden>" : $url;
|
||||
if($url !~ /^(http|https):\/\/([^:\/]+)(:\d+)?(\/.*)$/) {
|
||||
Log 1, "GetFileFromURL $url: malformed or unsupported URL";
|
||||
Log 1, "GetFileFromURL $displayurl: malformed or unsupported URL";
|
||||
return undef;
|
||||
}
|
||||
|
||||
@ -82,13 +82,29 @@ GetFileFromURL($@)
|
||||
}
|
||||
|
||||
$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;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
##################
|
||||
# Compatibility mode
|
||||
|
||||
sub
|
||||
GetFileFromURL($@)
|
||||
{
|
||||
my ($url, @a)= @_;
|
||||
return CustomGetFileFromURL(0, $url, @a);
|
||||
}
|
||||
|
||||
sub
|
||||
GetFileFromURLQuiet($@)
|
||||
{
|
||||
my ($url, @a)= @_;
|
||||
return CustomGetFileFromURL(1, $url, @a);
|
||||
}
|
||||
|
||||
sub
|
||||
GetHttpFile($$)
|
||||
{
|
||||
@ -96,4 +112,5 @@ GetHttpFile($$)
|
||||
return GetFileFromURL("http://$host$file");
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user