2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-03 04:36:36 +00:00

HttpUtils.pm: Chunked encoding (Forum #43376)

git-svn-id: https://svn.fhem.de/fhem/trunk@9753 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-11-02 11:05:25 +00:00
parent b8d3166a32
commit a01de174f4

View File

@ -395,7 +395,29 @@ HttpUtils_ParseAnswer($$)
}
}
}
if( $hash->{httpheader} =~ m/^Transfer-Encoding: Chunked/mi ) {
my $data;
my $header;
my ($size, $offset) = (length($ret), 0);
while( $offset < $size ) {
my $next = index($ret, "\r\n", $offset);
last if( $next == -1 );
if( substr($ret,$offset,$next-$offset) =~ m/([\da-f]+)/ ) {
my $len = hex($1);
$offset = $next + 2;
$data .= substr($ret,$offset,$len);
$offset += $len + 2;
next if( $len > 0 );
}
$hash->{httpheader} .= substr($ret,$offset);
}
$ret = $data;
}
# Debug
Log3 $hash, $hash->{loglevel},
"HttpUtils $hash->{displayurl}: Got data, length: ". length($ret);
@ -406,6 +428,7 @@ HttpUtils_ParseAnswer($$)
Log3 $hash, $hash->{loglevel}, " $_";
}
}
return ("", $ret);
}