From e7c2c4e3945df80f3ff714891e080085c70d6986 Mon Sep 17 00:00:00 2001 From: borisneubert <> Date: Sat, 1 Dec 2012 17:27:15 +0000 Subject: [PATCH] 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 --- fhem/FHEM/HttpUtils.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fhem/FHEM/HttpUtils.pm b/fhem/FHEM/HttpUtils.pm index 4b266c536..4a4df1674 100644 --- a/fhem/FHEM/HttpUtils.pm +++ b/fhem/FHEM/HttpUtils.pm @@ -54,7 +54,7 @@ CustomGetFileFromURL($$@) my $displayurl= $quiet ? "" : $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 ? "" : $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; }