2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-05 17:48:44 +00:00

Log the header if the requested data has zero length in CustomGetFileFromURL()

git-svn-id: https://svn.fhem.de/fhem/trunk@2244 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
borisneubert 2012-12-01 17:27:15 +00:00
parent dbfcc9cbea
commit e7c2c4e394

View File

@ -54,7 +54,7 @@ CustomGetFileFromURL($$@)
my $displayurl= $quiet ? "<hidden>" : $url;
if($url !~ /^(http|https):\/\/([^:\/]+)(:\d+)?(\/.*)$/) {
Log 1, "GetFileFromURL $displayurl: malformed or unsupported URL";
Log 1, "CustomGetFileFromURL $displayurl: malformed or unsupported URL";
return undef;
}
@ -80,7 +80,7 @@ CustomGetFileFromURL($$@)
$conn = IO::Socket::INET->new(PeerAddr=>"$host:$port", Timeout=>$timeout);
}
if(!$conn) {
Log 1, "GetFileFromURL: Can't connect to $protocol://$host:$port\n";
Log 1, "CustomGetFileFromURL $displayurl: Can't connect to $protocol://$host:$port\n";
undef $conn;
return undef;
}
@ -103,7 +103,7 @@ CustomGetFileFromURL($$@)
vec($rin, $conn->fileno(), 1) = 1;
my $nfound = select($rout=$rin, undef, undef, $timeout);
if($nfound <= 0) {
Log 1, "GetFileFromURL $displayurl: Select timeout/error: $!";
Log 1, "CustomGetFileFromURL $displayurl: Select timeout/error: $!";
undef $conn;
return undef;
}
@ -114,8 +114,15 @@ CustomGetFileFromURL($$@)
}
$ret=~ s/(.*?)\r\n\r\n//s; # Not greedy: switch off the header.
my @header= split("\r\n", $1);
my $hostpath= $quiet ? "<hidden>" : $host . $path;
Log 4, "GetFileFromURL: Got http://$hostpath, length: ".length($ret);
Log 4, "CustomGetFileFromURL $displayurl: Got data, length: ".length($ret);
if(!length($ret)) {
Log 4, "CustomGetFileFromURL $displayurl: Zero length data, header follows...";
for (@header) {
Log 4, "CustomGetFileFromURL $displayurl: $_";
}
}
undef $conn;
return $ret;
}