From 2f1757da99a6a5a38742e3328c6b13d5f9434dfe Mon Sep 17 00:00:00 2001 From: rudolfkoenig Date: Thu, 8 Feb 2018 11:56:39 +0000 Subject: [PATCH] 01_FHEMWEB.pm: implement allowedHttpHeaders (Forum #83967) git-svn-id: https://svn.fhem.de/fhem/trunk@16116 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/01_FHEMWEB.pm | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/fhem/FHEM/01_FHEMWEB.pm b/fhem/FHEM/01_FHEMWEB.pm index 529e57651..4119cbb96 100644 --- a/fhem/FHEM/01_FHEMWEB.pm +++ b/fhem/FHEM/01_FHEMWEB.pm @@ -149,6 +149,7 @@ FHEMWEB_Initialize($) csrfToken csrfTokenHTTPHeader:0,1 alarmTimeout + allowedHttpMethods allowedCommands allowfrom basicAuth @@ -419,7 +420,8 @@ FW_Read($$) my ($method, $arg, $httpvers) = split(" ", $FW_httpheader[0], 3) if($FW_httpheader[0]); $method = "" if(!$method); - if($method !~ m/^(GET|POST)$/i){ + my $ahm = AttrVal($FW_wname, "allowedHttpMethods", "GET|POST"); + if($method !~ m/^($ahm)$/i){ my $retCode = ($method eq "OPTIONS") ? "200 OK" : "405 Method Not Allowed"; TcpServer_WriteBlocking($FW_chash, "HTTP/1.1 $retCode\r\n" . @@ -3338,6 +3340,15 @@ FW_widgetOverride($$) instance from now on.
+
  • allowedHttpMethods
    + FHEMWEB implements the GET, POST and OPTIONS HTTP methods. Some external + devices require the HEAD method, which is not implemented correctly in + FHEMWEB, as FHEMWEB always returns a body, which, according to the spec, + is wrong. As in some cases this not a problem, enabling GET may work. + To do this, set this attribute to GET|POST|HEAD, default ist GET|POST. + OPTIONS is always enabled. +

  • +
  • closeConn
    If set, a TCP Connection will only serve one HTTP request. Seems to @@ -4028,6 +4039,17 @@ FW_widgetOverride($$) für eine FHEMWEB Instanz unerwünscht.

  • +
  • allowedHttpMethods
    + FHEMWEB implementiert die HTTP Methoden GET, POST und OPTIONS. Manche + externe Geräte benötigen HEAD, das ist aber in FHEMWEB nicht + korrekt implementiert, da FHEMWEB immer ein body zurückliefert, was + laut Spec falsch ist. Da ein body in manchen Fällen kein Problem + ist, kann man HEAD durch setzen dieses Attributes auf HEAD|POST|HEAD + aktivieren, die Voreinstellung ist HEAD|POST. OPTIONS ist immer + aktiviert. +

  • + +
  • closeConn
    Falls gesetzt, wird pro TCP Verbindung nur ein HTTP Request