mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
01_FHEMWEB.pm: return 405 on unknown method, fix IE warning
git-svn-id: https://svn.fhem.de/fhem/trunk@13126 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1c98891a5e
commit
16001e2e04
@ -413,17 +413,18 @@ FW_Read($$)
|
|||||||
my @origin = grep /Origin/i, @FW_httpheader;
|
my @origin = grep /Origin/i, @FW_httpheader;
|
||||||
$FW_headerlines = (AttrVal($FW_wname, "CORS", 0) ?
|
$FW_headerlines = (AttrVal($FW_wname, "CORS", 0) ?
|
||||||
(($#origin<0) ? "": "Access-Control-Allow-".$origin[0]."\r\n").
|
(($#origin<0) ? "": "Access-Control-Allow-".$origin[0]."\r\n").
|
||||||
"Access-Control-Allow-Methods: GET OPTIONS\r\n".
|
"Access-Control-Allow-Methods: GET POST OPTIONS\r\n".
|
||||||
"Access-Control-Allow-Headers: Origin, Authorization, Accept\r\n".
|
"Access-Control-Allow-Headers: Origin, Authorization, Accept\r\n".
|
||||||
"Access-Control-Allow-Credentials: true\r\n".
|
"Access-Control-Allow-Credentials: true\r\n".
|
||||||
"Access-Control-Max-Age:86400\r\n" : "");
|
"Access-Control-Max-Age:86400\r\n" : "");
|
||||||
|
|
||||||
#############################
|
#########################
|
||||||
# Handle OPTIONS Request. Just reeturn headers and don't process any further.
|
# Return 200 for OPTIONS or 405 for unsupported method
|
||||||
my ($method, $arg, $httpvers) = split(" ", $FW_httpheader[0], 3);
|
my ($method, $arg, $httpvers) = split(" ", $FW_httpheader[0], 3);
|
||||||
if($method !~ m/^(GET|POST)$/i){
|
if($method !~ m/^(GET|POST)$/i){
|
||||||
|
my $retCode = ($method eq "OPTIONS") ? 200 : 405;
|
||||||
TcpServer_WriteBlocking($FW_chash,
|
TcpServer_WriteBlocking($FW_chash,
|
||||||
"HTTP/1.1 200 OK\r\n" .
|
"HTTP/1.1 $retCode OK\r\n" .
|
||||||
$FW_headerlines.
|
$FW_headerlines.
|
||||||
"Content-Length: 0\r\n\r\n");
|
"Content-Length: 0\r\n\r\n");
|
||||||
delete $hash->{CONTENT_LENGTH};
|
delete $hash->{CONTENT_LENGTH};
|
||||||
@ -1566,7 +1567,7 @@ FW_roomOverview($)
|
|||||||
|
|
||||||
if($l1 eq "Save config") {
|
if($l1 eq "Save config") {
|
||||||
$l1 .= '</a> <a id="saveCheck" class="changed" style="visibility:'.
|
$l1 .= '</a> <a id="saveCheck" class="changed" style="visibility:'.
|
||||||
(int(@structChangeHist) ? 'visible' : 'hidden').'">?</a>';
|
(int(@structChangeHist) ? 'visible' : 'hidden').'">?';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Force external browser if FHEMWEB is installed as an offline app.
|
# Force external browser if FHEMWEB is installed as an offline app.
|
||||||
|
@ -879,6 +879,7 @@ FW_longpoll()
|
|||||||
} else {
|
} else {
|
||||||
FW_pollConn = new XMLHttpRequest();
|
FW_pollConn = new XMLHttpRequest();
|
||||||
FW_pollConn.open("GET", location.pathname+query, true);
|
FW_pollConn.open("GET", location.pathname+query, true);
|
||||||
|
FW_pollConn.overrideMimeType("application/json");
|
||||||
FW_pollConn.onreadystatechange = FW_doUpdate;
|
FW_pollConn.onreadystatechange = FW_doUpdate;
|
||||||
FW_pollConn.send(null);
|
FW_pollConn.send(null);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user