From bbba93e91222442cc8ee1dd27f6115e45cd021ce Mon Sep 17 00:00:00 2001 From: MichaelDaum Date: Wed, 15 Apr 2015 11:07:45 +0200 Subject: [PATCH] Item13375: fixed setting the content-encoding ... under each and every circumstance --- core/lib/Foswiki.pm | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/core/lib/Foswiki.pm b/core/lib/Foswiki.pm index ac49843138..5f5f3c57ad 100644 --- a/core/lib/Foswiki.pm +++ b/core/lib/Foswiki.pm @@ -1002,19 +1002,12 @@ sub generateHTTPHeaders { # add http compression and conditional cache controls if ( !$this->inContext('command_line') && $text ) { - if ( - $Foswiki::cfg{HttpCompress} - && ( - ( - $ENV{'HTTP_ACCEPT_ENCODING'} - && $ENV{'HTTP_ACCEPT_ENCODING'} =~ m/(x-gzip|gzip)/i - ) - - || $ENV{'SPDY'} - ) - ) # SMELL: non-standard way to detect spdy protocol set by web server - { - my $encoding = $1 || 'gzip'; + if ( $Foswiki::cfg{HttpCompress} + && ( $ENV{'HTTP_ACCEPT_ENCODING'} || $ENV{'SPDY'} ) ) + { # SMELL: SPDY is a non-standard way to detect spdy protocol set by web server + my $encoding = $ENV{'HTTP_ACCEPT_ENCODING'} || 'gzip'; + $encoding =~ s/^.*(x-gzip|gzip).*/$1/g; + $hopts->{'Content-Encoding'} = $encoding; $hopts->{'Vary'} = 'Accept-Encoding';