2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-10 03:06:37 +00:00

01_FHEMWEB.pm: workaround for iOS9 WebApp startup problem (Forum #41125)

git-svn-id: https://svn.fhem.de/fhem/trunk@9321 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2015-09-27 12:44:35 +00:00
parent 6e10217fa6
commit e800cfc742
2 changed files with 26 additions and 5 deletions

View File

@ -140,6 +140,7 @@ FHEMWEB_Initialize($)
allowfrom
basicAuth
basicAuthMsg
closeConn:1,0
column
defaultRoom
editConfig:1,0
@ -318,7 +319,6 @@ FW_Read($$)
}
}
if(!$hash->{HDR}) {
return if($hash->{BUF} !~ m/^(.*?)(\n\n|\r\n\r\n)(.*)$/s);
$hash->{HDR} = $1;
@ -402,7 +402,7 @@ FW_Read($$)
$hash->{LASTACCESS} = $now;
$arg = "" if(!defined($arg));
Log3 $FW_wname, 4, "HTTP $name GET $arg";
Log3 $FW_wname, 4, "$name $method $arg; BUFLEN:".length($hash->{BUF});
$FW_ME = "/" . AttrVal($FW_wname, "webname", "fhem");
my $pf = AttrVal($FW_wname, "plotfork", undef);
if($pf) { # 0 disables
@ -457,7 +457,7 @@ FW_Read($$)
my $expires = ($cacheable?
("Expires: ".FmtDateTimeRFC1123($now+900)."\r\n") : "");
Log3 $FW_wname, 4,
"$$:$name: $arg / RL:$length / $FW_RETTYPE / $compressed / $expires";
"name: $arg / RL:$length / $FW_RETTYPE / $compressed / $expires";
if( ! addToWritebuffer($hash,
"HTTP/1.1 200 OK\r\n" .
"Content-Length: $length\r\n" .
@ -476,6 +476,14 @@ sub
FW_closeConn($)
{
my ($hash) = @_;
if(!$hash->{inform} && !$hash->{BUF}) { # Forum #41125
my $cc = AttrVal($hash->{SNAME}, "closeConn",
$FW_userAgent=~m/(iPhone|iPad|iPod)/);
if(!$FW_httpheader{Connection} || $cc) {
TcpServer_Close($hash);
delete($defs{$hash->{NAME}});
}
}
POSIX::exit(0) if($hash->{isChild});
FW_Read($hash, 1) if($hash->{BUF});
}
@ -1578,6 +1586,7 @@ FW_returnFileAsStream($$$$$)
my $rsp = "Date: ".FmtDateTimeRFC1123($now)."\r\n".
"ETag: $etag\r\n".
"Expires: ".FmtDateTimeRFC1123($now+900)."\r\n";
Log3 $FW_wname, 4, "$FW_chash->{NAME} => 304 Not Modified";
TcpServer_WriteBlocking($FW_chash,"HTTP/1.1 304 Not Modified\r\n".
$rsp . $FW_headercors . "\r\n");
return -1;
@ -3381,6 +3390,13 @@ FW_widgetOverride($$)
attribute.
</li>
<a name="closeConn"></a>
<li>closeConn<br>
If set, a TCP Connection will only serve one HTTP request. Seems to
solve problems on iOS9 for WebApp startup.
</li><br>
<a name="CssFiles"></a>
<li>CssFiles<br>
Space separated list of .css files to be included. The filenames
@ -4088,6 +4104,12 @@ FW_widgetOverride($$)
%20 zu schreiben.
</li><br>
<a name="closeConn"></a>
<li>closeConn<br>
Falls gesetzt, wird pro TCP Verbindung nur ein HTTP Request
durchgef&uuml;hrt. F&uuml;r iOS9 WebApp startups scheint es zu helfen.
</li><br>
<a name="CssFiles"></a>
<li>CssFiles<br>
Leerzeichen getrennte Liste von .css Dateien, die geladen werden.

View File

@ -9,6 +9,7 @@ attr global sendStatistics never
attr global statefile ./demolog/fhem.save
attr global updateInBackground 1
attr global verbose 3
attr global mseclog
define telnetPort telnet 7072 global
attr telnetPort room System
@ -27,7 +28,6 @@ attr WEBphone iconPath openautomation:fhemSVG:default
attr WEBphone room System
attr WEBphone sortRooms Light Cinema Residents Sensors System
attr WEBphone stylesheetPrefix smallscreen
attr WEBphone plotEmbed 0
define WEBtablet FHEMWEB 8085 global
attr WEBtablet hiddenroom DashboardRoom
@ -35,7 +35,6 @@ attr WEBtablet iconPath openautomation:fhemSVG:default
attr WEBtablet room System
attr WEBtablet sortRooms Light Cinema Residents Sensors System
attr WEBtablet stylesheetPrefix ios7touchpad
attr WEBtablet plotEmbed 0
# Fake FileLog entry, to access the fhem log from FHEMWEB
define Logfile FileLog ./log/fhem-%Y-%m.log fakelog