mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
01_FHEMWEB.pm: Collect some statistics & limit header size
git-svn-id: https://svn.fhem.de/fhem/trunk@21298 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
320de372dc
commit
79d41e5fa3
@ -305,6 +305,8 @@ FW_Define($$)
|
|||||||
}
|
}
|
||||||
}, $hash, 0);
|
}, $hash, 0);
|
||||||
}
|
}
|
||||||
|
$hash->{BYTES_READ} = 0;
|
||||||
|
$hash->{BYTES_WRITTEN} = 0;
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@ -362,11 +364,15 @@ FW_Read($$)
|
|||||||
(defined($ret) ? 'EOF' : $!);
|
(defined($ret) ? 'EOF' : $!);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
my $sh = $defs{$FW_wname};
|
||||||
|
$sh->{BYTES_READ} += length($buf);
|
||||||
|
|
||||||
$hash->{BUF} .= $buf;
|
$hash->{BUF} .= $buf;
|
||||||
if($hash->{SSL} && $c->can('pending')) {
|
if($hash->{SSL} && $c->can('pending')) {
|
||||||
while($c->pending()) {
|
while($c->pending()) {
|
||||||
sysread($c, $buf, 1024);
|
sysread($c, $buf, 1024);
|
||||||
$hash->{BUF} .= $buf;
|
$hash->{BUF} .= $buf;
|
||||||
|
$sh->{BYTES_READ} += length($buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -421,6 +427,10 @@ FW_Read($$)
|
|||||||
|
|
||||||
|
|
||||||
if(!$hash->{HDR}) {
|
if(!$hash->{HDR}) {
|
||||||
|
if(length($hash->{BUF}) > 1000000) {
|
||||||
|
Log3 $FW_wname, 2, "Too much header, terminating $hash->{PEER}";
|
||||||
|
return TcpServer_Close($hash, 1);
|
||||||
|
}
|
||||||
return if($hash->{BUF} !~ m/^(.*?)(\n\n|\r\n\r\n)(.*)$/s);
|
return if($hash->{BUF} !~ m/^(.*?)(\n\n|\r\n\r\n)(.*)$/s);
|
||||||
$hash->{HDR} = $1;
|
$hash->{HDR} = $1;
|
||||||
$hash->{BUF} = $3;
|
$hash->{BUF} = $3;
|
||||||
@ -429,6 +439,7 @@ FW_Read($$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log3 $FW_wname, 5, $hash->{HDR};
|
||||||
my $POSTdata = "";
|
my $POSTdata = "";
|
||||||
if($hash->{CONTENT_LENGTH}) {
|
if($hash->{CONTENT_LENGTH}) {
|
||||||
return if(length($hash->{BUF})<$hash->{CONTENT_LENGTH});
|
return if(length($hash->{BUF})<$hash->{CONTENT_LENGTH});
|
||||||
@ -714,6 +725,7 @@ FW_addToWritebuffer($$@)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$defs{$hash->{SNAME}}{BYTES_WRITTEN} += length($txt);
|
||||||
return addToWritebuffer($hash, $txt, $callback, $nolimit);
|
return addToWritebuffer($hash, $txt, $callback, $nolimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,6 +334,8 @@ TcpServer_WriteBlocking($$)
|
|||||||
|
|
||||||
if( defined $ret ){
|
if( defined $ret ){
|
||||||
$off += $ret;
|
$off += $ret;
|
||||||
|
my $sh = $defs{$hash->{SNAME}};
|
||||||
|
$sh->{BYTES_WRITTEN} += $ret if(defined($sh->{BYTES_WRITTEN}));
|
||||||
|
|
||||||
} elsif( $! == EWOULDBLOCK ){
|
} elsif( $! == EWOULDBLOCK ){
|
||||||
$hash->{wantRead} = 1
|
$hash->{wantRead} = 1
|
||||||
|
Loading…
Reference in New Issue
Block a user