From 05347a7240b1d447f56748647eec5f861daf6f69 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Tue, 17 Jan 2017 21:40:09 +0000 Subject: [PATCH] 01_FHEMWEB.pm: allow setting of content-type for XHR commands (jsonlist/xmllist) (Forum #14491) git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@13128 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- FHEM/01_FHEMWEB.pm | 4 +++- FHEM/98_JsonList2.pm | 2 ++ FHEM/98_XmlList.pm | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/FHEM/01_FHEMWEB.pm b/FHEM/01_FHEMWEB.pm index c985d5910..ad4472cb6 100755 --- a/FHEM/01_FHEMWEB.pm +++ b/FHEM/01_FHEMWEB.pm @@ -820,7 +820,9 @@ FW_answerCall($) #If we are in XHR or json mode, execute the command directly if($FW_XHR || $FW_jsonp) { $FW_cmdret = $docmd ? FW_fC($cmd, $cmddev) : undef; - $FW_RETTYPE = "text/plain; charset=$FW_encoding"; + $FW_RETTYPE = $FW_chash->{contenttype} ? + $FW_chash->{contenttype} : "text/plain; charset=$FW_encoding"; + delete($FW_chash->{contenttype}); if($FW_jsonp) { $FW_cmdret =~ s/'/\\'/g; diff --git a/FHEM/98_JsonList2.pm b/FHEM/98_JsonList2.pm index c13f178cf..f8f61db2c 100644 --- a/FHEM/98_JsonList2.pm +++ b/FHEM/98_JsonList2.pm @@ -70,6 +70,8 @@ CommandJsonList2($$) my $si = AttrVal("global", "showInternalValues", 0); my $attr; + $cl->{contenttype} = "application/json; charset=utf-8" if($cl); + if($param) { my @arg = split(" ", $param); $attr = $arg[1]; diff --git a/FHEM/98_XmlList.pm b/FHEM/98_XmlList.pm index 25aa3478a..00acdca20 100644 --- a/FHEM/98_XmlList.pm +++ b/FHEM/98_XmlList.pm @@ -47,6 +47,8 @@ CommandXmlList($$) my $lt = ""; my %filter; + $cl->{contenttype} = "application/xml; charset=utf-8" if($cl); + my @arr = devspec2array($param ? $param : ".*", $cl); # for Authorize map { $filter{$_} = 1 } @arr;