2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 12:58:13 +00:00

dim06% problems

git-svn-id: https://svn.fhem.de/fhem/trunk@1155 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2011-12-30 19:21:35 +00:00
parent 2e14178410
commit 3b46a44d08

View File

@ -121,8 +121,10 @@ CommandUpdatefhem($$)
}
my $content = GetHttpFile($server, "$sdir/$remfile");
return "File size for $f does not correspond to filetimes.txt entry"
if(length($content) ne $filesize{$f});
my $l1 = length($content);
my $l2 = $filesize{$f};
return "File size for $f ($l1) does not correspond to ".
"filetimes.txt entry ($l2)" if($l1 ne $l2);
open(FH,">$localfile") || return "Can't write $localfile";
print FH $content;
close(FH)
@ -210,6 +212,7 @@ GetHttpFile($$)
{
my ($host, $filename) = @_;
$filename =~ s/%/%25/g;
my $conn = IO::Socket::INET->new(PeerAddr => $host);
if(!$conn) {
Log 1, "Can't connect to $host\n";
@ -219,10 +222,10 @@ GetHttpFile($$)
my $req = "GET $filename HTTP/1.0\r\nHost: $host\r\n\r\n\r\n";
syswrite $conn, $req;
my ($buf, $ret);
while(sysread($conn, $buf, 65536) > 0) {
while(sysread($conn,$buf,65536) > 0) {
$ret .= $buf;
}
$ret=~ s/.*?\r\n\r\n//s;
$ret=~ s/(.*?)\r\n\r\n//s; # Not greedy: switch off the header.
Log 1, "Got http://$host$filename, length: ".length($ret);
return $ret;
}