mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
01_FHEMWEB.pm: remove the closeConn attribute (Forum #20294)
git-svn-id: https://svn.fhem.de/fhem/trunk@8722 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
efe997eaa2
commit
4bcd9fc282
@ -47,6 +47,7 @@ sub FW_textfieldv($$$$);
|
|||||||
sub FW_updateHashes();
|
sub FW_updateHashes();
|
||||||
sub FW_visibleDevices(;$);
|
sub FW_visibleDevices(;$);
|
||||||
sub FW_widgetOverride($$);
|
sub FW_widgetOverride($$);
|
||||||
|
sub FW_Read($$);
|
||||||
|
|
||||||
use vars qw($FW_dir); # base directory for web server
|
use vars qw($FW_dir); # base directory for web server
|
||||||
use vars qw($FW_icondir); # icon base directory
|
use vars qw($FW_icondir); # icon base directory
|
||||||
@ -139,7 +140,6 @@ FHEMWEB_Initialize($)
|
|||||||
allowfrom
|
allowfrom
|
||||||
basicAuth
|
basicAuth
|
||||||
basicAuthMsg
|
basicAuthMsg
|
||||||
closeConn:1,0
|
|
||||||
column
|
column
|
||||||
defaultRoom
|
defaultRoom
|
||||||
editConfig:1,0
|
editConfig:1,0
|
||||||
@ -257,9 +257,9 @@ FW_Undef($$)
|
|||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub
|
||||||
FW_Read($)
|
FW_Read($$)
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash, $reread) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|
||||||
if($hash->{SERVERSOCKET}) { # Accept and create a child
|
if($hash->{SERVERSOCKET}) { # Accept and create a child
|
||||||
@ -293,39 +293,46 @@ FW_Read($)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Data from HTTP Client
|
if(!$reread) {
|
||||||
my $buf;
|
# Data from HTTP Client
|
||||||
my $ret = sysread($c, $buf, 1024);
|
my $buf;
|
||||||
|
my $ret = sysread($c, $buf, 1024);
|
||||||
|
|
||||||
if(!defined($ret) && $! == EWOULDBLOCK ){
|
if(!defined($ret) && $! == EWOULDBLOCK ){
|
||||||
$hash->{wantWrite} = 1
|
$hash->{wantWrite} = 1
|
||||||
if(TcpServer_WantWrite($hash));
|
if(TcpServer_WantWrite($hash));
|
||||||
return;
|
return;
|
||||||
} elsif(!$ret) { # 0==EOF, undef=error
|
} elsif(!$ret) { # 0==EOF, undef=error
|
||||||
CommandDelete(undef, $name);
|
CommandDelete(undef, $name);
|
||||||
Log3 $FW_wname, 4, "Connection closed for $name: ".
|
Log3 $FW_wname, 4, "Connection closed for $name: ".
|
||||||
(defined($ret) ? 'EOF' : $!);
|
(defined($ret) ? 'EOF' : $!);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$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;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!$hash->{HDR}) {
|
if(!$hash->{HDR}) {
|
||||||
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;
|
||||||
if($hash->{HDR} =~ m/Content-Length: ([^\r\n]*)/s) {
|
if($hash->{HDR} =~ m/Content-Length: ([^\r\n]*)/s) {
|
||||||
$hash->{CONTENT_LENGTH} = $1;
|
$hash->{CONTENT_LENGTH} = $1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return if($hash->{CONTENT_LENGTH} &&
|
|
||||||
length($hash->{BUF})<$hash->{CONTENT_LENGTH});
|
my $POSTdata = "";
|
||||||
|
if($hash->{CONTENT_LENGTH}) {
|
||||||
|
return if(length($hash->{BUF})<$hash->{CONTENT_LENGTH});
|
||||||
|
$POSTdata = substr($hash->{BUF}, 0, $hash->{CONTENT_LENGTH});
|
||||||
|
$hash->{BUF} = substr($hash->{BUF}, $hash->{CONTENT_LENGTH});
|
||||||
|
}
|
||||||
|
|
||||||
@FW_httpheader = split(/[\r\n]+/, $hash->{HDR});
|
@FW_httpheader = split(/[\r\n]+/, $hash->{HDR});
|
||||||
%FW_httpheader = map {
|
%FW_httpheader = map {
|
||||||
@ -369,7 +376,7 @@ FW_Read($)
|
|||||||
$FW_headercors.
|
$FW_headercors.
|
||||||
"Content-Length: 0\r\n\r\n");
|
"Content-Length: 0\r\n\r\n");
|
||||||
delete $hash->{CONTENT_LENGTH};
|
delete $hash->{CONTENT_LENGTH};
|
||||||
delete $hash->{BUF};
|
FW_Read($hash, 1) if($hash->{BUF});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if(!$pwok) {
|
if(!$pwok) {
|
||||||
@ -380,7 +387,7 @@ FW_Read($)
|
|||||||
$FW_headercors.
|
$FW_headercors.
|
||||||
"Content-Length: 0\r\n\r\n");
|
"Content-Length: 0\r\n\r\n");
|
||||||
delete $hash->{CONTENT_LENGTH};
|
delete $hash->{CONTENT_LENGTH};
|
||||||
delete $hash->{BUF};
|
FW_Read($hash, 1) if($hash->{BUF});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -388,9 +395,8 @@ FW_Read($)
|
|||||||
|
|
||||||
my $now = time();
|
my $now = time();
|
||||||
my ($method, $arg, $httpvers) = split(" ", $FW_httpheader[0], 3);
|
my ($method, $arg, $httpvers) = split(" ", $FW_httpheader[0], 3);
|
||||||
$arg .= "&".$hash->{BUF} if($hash->{CONTENT_LENGTH});
|
$arg .= "&".$POSTdata if($POSTdata);
|
||||||
delete $hash->{CONTENT_LENGTH};
|
delete $hash->{CONTENT_LENGTH};
|
||||||
delete $hash->{BUF};
|
|
||||||
$hash->{LASTACCESS} = $now;
|
$hash->{LASTACCESS} = $now;
|
||||||
|
|
||||||
$arg = "" if(!defined($arg));
|
$arg = "" if(!defined($arg));
|
||||||
@ -413,9 +419,11 @@ FW_Read($)
|
|||||||
# child.
|
# child.
|
||||||
TcpServer_Disown( $hash );
|
TcpServer_Disown( $hash );
|
||||||
delete($defs{$name});
|
delete($defs{$name});
|
||||||
|
FW_Read($hash, 1) if($hash->{BUF});
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} elsif(defined($pid)){ # child
|
} elsif(defined($pid)){ # child
|
||||||
|
delete $hash->{BUF};
|
||||||
$hash->{isChild} = 1;
|
$hash->{isChild} = 1;
|
||||||
|
|
||||||
} # fork failed and continue in parent
|
} # fork failed and continue in parent
|
||||||
@ -467,14 +475,8 @@ sub
|
|||||||
FW_closeConn($)
|
FW_closeConn($)
|
||||||
{
|
{
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
if(AttrVal($hash->{SNAME}, "closeConn", # Forum #20294
|
|
||||||
!$FW_httpheader{Connection} ||
|
|
||||||
$FW_httpheader{Connection} ne "keep-alive" ||
|
|
||||||
$FW_userAgent =~ m/(iPhone|iPad|iPod|Darwin)/)) {
|
|
||||||
TcpServer_Close($hash);
|
|
||||||
delete($defs{$hash->{NAME}});
|
|
||||||
}
|
|
||||||
POSIX::exit(0) if($hash->{isChild});
|
POSIX::exit(0) if($hash->{isChild});
|
||||||
|
FW_Read($hash, 1) if($hash->{BUF});
|
||||||
}
|
}
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
@ -3331,13 +3333,6 @@ FW_widgetOverride($$)
|
|||||||
attribute.
|
attribute.
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<a name="closeConn"></a>
|
|
||||||
<li>closeConn<br>
|
|
||||||
If set, a TCP Connection will only serve one HTTP request. Seems to
|
|
||||||
solve problems for certain hardware combinations like slow
|
|
||||||
FHEM-Server, and iPad/iPhone as Web-client.
|
|
||||||
</li><br>
|
|
||||||
|
|
||||||
<a name="CssFiles"></a>
|
<a name="CssFiles"></a>
|
||||||
<li>CssFiles<br>
|
<li>CssFiles<br>
|
||||||
Space separated list of .css files to be included. The filenames
|
Space separated list of .css files to be included. The filenames
|
||||||
@ -4034,14 +4029,6 @@ FW_widgetOverride($$)
|
|||||||
%20 zu schreiben.
|
%20 zu schreiben.
|
||||||
</li><br>
|
</li><br>
|
||||||
|
|
||||||
<a name="closeConn"></a>
|
|
||||||
<li>closeConn<br>
|
|
||||||
Falls gesetzt, wird pro TCP Verbindung nur ein HTTP Request
|
|
||||||
durchgefuehrt. Fuer bestimmte Hardware-Kombinationen (langsamer FHEM
|
|
||||||
Server, iPad/iPhone als Client) scheint dieses Attribu Ladeprobleme zu
|
|
||||||
beheben.
|
|
||||||
</li><br>
|
|
||||||
|
|
||||||
<a name="CssFiles"></a>
|
<a name="CssFiles"></a>
|
||||||
<li>CssFiles<br>
|
<li>CssFiles<br>
|
||||||
Leerzeichen getrennte Liste von .css Dateien, die geladen werden.
|
Leerzeichen getrennte Liste von .css Dateien, die geladen werden.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user