diff --git a/fhem/CHANGED b/fhem/CHANGED index 148785688..b63258810 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: HttpUtils: compression activated + disable it with attr global httpcompress 0 - bugfix: 46_SmartPi: fix syntax error bug in Attribut Sub - change: 98_dewpoint: Refactoring using API calls, verbose attribute added - change: FileLog removes newlines from the data (Forum #79684) diff --git a/fhem/FHEM/98_update.pm b/fhem/FHEM/98_update.pm index eb58ca3b5..979695fb7 100644 --- a/fhem/FHEM/98_update.pm +++ b/fhem/FHEM/98_update.pm @@ -496,7 +496,6 @@ upd_getUrl($) $url =~ s/%/%25/g; $upd_connecthash{url} = $url; $upd_connecthash{keepalive} = ($url =~ m/localUpdate/ ? 0 : 1); # Forum #49798 - # $upd_connecthash{compress} = 1; # fhem.de does not support compression my ($err, $data) = HttpUtils_BlockingGet(\%upd_connecthash); if($err) { uLog 1, $err; diff --git a/fhem/FHEM/HttpUtils.pm b/fhem/FHEM/HttpUtils.pm index 64f07e1e4..c11228d2b 100644 --- a/fhem/FHEM/HttpUtils.pm +++ b/fhem/FHEM/HttpUtils.pm @@ -82,6 +82,7 @@ HttpUtils_Close($) delete($hash->{hu_port}); delete($hash->{directReadFn}); delete($hash->{directWriteFn}); + delete($hash->{compress}); } sub @@ -342,6 +343,17 @@ HttpUtils_Connect($) } } + if((!defined($hash->{compress}) || $hash->{compress}) && + AttrVal("global", "httpcompress", 1)) { + if(!defined($HU_use_zlib)) { + $HU_use_zlib = 1; + eval { require Compress::Zlib; }; + $HU_use_zlib = 0 if($@); + } + $hash->{compress} = $HU_use_zlib; + } + + return HttpUtils_Connect2($hash) if($hash->{conn} && $hash->{keepalive}); if($hash->{callback}) { # Nonblocking staff @@ -409,15 +421,6 @@ HttpUtils_Connect($) if(!$hash->{conn}); } - if($hash->{compress}) { - if(!defined($HU_use_zlib)) { - $HU_use_zlib = 1; - eval { require Compress::Zlib; }; - $HU_use_zlib = 0 if($@); - } - $hash->{compress} = $HU_use_zlib; - } - return HttpUtils_Connect2($hash); } @@ -530,7 +533,8 @@ HttpUtils_Connect2($) $hdr .= "Connection: Close\r\n" if($httpVersion ne "1.0" && !$hash->{keepalive}); - $hdr .= "Authorization: Basic ".encode_base64($hash->{user}.":".$hash->{pwd}, "")."\r\n" + $hdr .= "Authorization: Basic ". + encode_base64($hash->{user}.":".$hash->{pwd}, "")."\r\n" if($hash->{auth} && !$hash->{digest} && !($hash->{header} && $hash->{header} =~ /^Authorization:\s*Digest/mi)); @@ -807,6 +811,11 @@ HttpUtils_ParseAnswer($) } } + if($hash->{httpheader} =~ /^Content-Encoding: gzip/mi && $HU_use_zlib) { + eval { $ret = Compress::Zlib::memGunzip($ret) }; + return ($@, $ret) if($@); + } + # Debug Log3 $hash, $hash->{loglevel}+1, "HttpUtils $hash->{displayurl}: Got data, length: ". length($ret); @@ -822,8 +831,9 @@ HttpUtils_ParseAnswer($) # digest(0),hideurl(0),timeout(4),data(""),loglevel(4),header("" or HASH), # noshutdown(1),shutdown(0),httpversion("1.0"),ignoreredirects(0) # method($data?"POST":"GET"),keepalive(0),sslargs({}),user(),pwd() +# compress(1) # Example: -# { HttpUtils_NonblockingGet({ url=>"http://www.google.de/", +# { HttpUtils_NonblockingGet({ url=>"http://fhem.de/MAINTAINER.txt", # callback=>sub($$$){ Log 1,"ERR:$_[1] DATA:".length($_[2]) } }) } sub HttpUtils_NonblockingGet($) diff --git a/fhem/docs/commandref_frame.html b/fhem/docs/commandref_frame.html index fb7e2399b..7e49d5306 100644 --- a/fhem/docs/commandref_frame.html +++ b/fhem/docs/commandref_frame.html @@ -1448,6 +1448,13 @@ The following local attributes are used by a wider range of devices: OS implementation (inet_aton and gethostbyname) will be used.
+ +
  • featurelevel
    + Enable/disable old or new features, based on FHEM version. + E.g. the $value hash for notify is only set for featurelevel up to 5.6, + as it is deprecated, use the Value() function instead. +

  • +
  • holiday2we
    If this attribute is set, then the $we variable @@ -1459,11 +1466,10 @@ The following local attributes are used by a wider range of devices:

  • - -
  • featurelevel
    - Enable/disable old or new features, based on FHEM version. - E.g. the $value hash for notify is only set for featurelevel up to 5.6, - as it is deprecated, use the Value() function instead. + +
  • httpcompress
    + the HttpUtils module is used by a lot of FHEM modules, and enables + compression by default. Set httpcompress to 0 to disable this feature.

  • diff --git a/fhem/docs/commandref_frame_DE.html b/fhem/docs/commandref_frame_DE.html index 3c887e512..0166d8ca4 100644 --- a/fhem/docs/commandref_frame_DE.html +++ b/fhem/docs/commandref_frame_DE.html @@ -1541,6 +1541,13 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet: bzw gethostbyname aufgerufen.
    + +
  • featurelevel
    + Aktiviere bzw. deaktiviere bestimmte alte oder neue Funktionen, basierend + auf die FHEM Version. Z.Bsp. das $value hash für notify wird nur bis featurelevel 5.6 + befüllt, da es unerwünscht ist. Stattdessen sollte man die + Value() Funktion verwenden. +

  • holiday2we
    @@ -1554,12 +1561,11 @@ Die folgenden lokalen Attribute werden von mehreren Geräten verwendet:

  • - -
  • featurelevel
    - Aktiviere bzw. deaktiviere bestimmte alte oder neue Funktionen, basierend - auf die FHEM Version. Z.Bsp. das $value hash für notify wird nur bis featurelevel 5.6 - befüllt, da es unerwünscht ist. Stattdessen sollte man die - Value() Funktion verwenden. + +
  • httpcompress
    + das HttpUtils Modul wird von etlichen FHEM modulen verwendet und + aktiviert Komprimierung in der Voreinstellung. Falls man + httpcompress auf 0 setzt, wird die Komprimierung deaktiviert.

  • diff --git a/fhem/fhem.pl b/fhem/fhem.pl index f8210362a..47ef763b8 100755 --- a/fhem/fhem.pl +++ b/fhem/fhem.pl @@ -301,9 +301,10 @@ my @globalAttrList = qw( dnsServer dupTimeout exclude_from_update - featurelevel + featurelevel:5.5,5.6,5.7,5,8,99.99 genericDisplayType:switch,outlet,light,blind,speaker,thermostat holiday2we + httpcompress:0,1 language:EN,DE lastinclude latitude