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.
+
+