Allow forcing the Content-Encoding: gzip header

#1
Hello,

I am trying to implement some code with PHP to do a technique described by Steve Sounders (do a Google Search for 'forcing gzip compression').

The simplest part of this is having a script that is always gzipped. To do this I need to set a header like so

Code:
header("Content-Encoding: gzip");
The problem is this header still needs to be set if Accept-Encoding is missing or does not include "gzip" or "deflate".

This works fine on other server softwares and various other tests I have done. I am running into an issue with LiteSpeed however: If I don't set Accept-Encoding via the browser LiteSpeed and PHP ignore my Content-Encoding line and the output of the page is not forced.

The following is a test and directions on how you can easily replicate this problem:
  1. Stick pastebin.com/2L0f9C6y on a LiteSpeed server with PHP active.
  2. Install addons.mozilla.org/en-US/firefox/addon/966/ so that you can disable the Accept-Encoding header.
  3. Open the tamper plugin and click "Start Tamper" and load the script. It should give you a popup. Uncheck "Continue Tamper" and click the Tamper button. You can remove the Accept-Encoding header by right clicking and and selecting delete. Hit OK.

When you load the script with Accept-Encoding and view the headers for the page you will notice Content-Encoding is not set. If you refresh and leave Accept-Encoding intact Content-Encoding is set. Again, this works on other server softwares and seems to be something LiteSpeed related.

Is there a configuration option somewhere where I can tell Litespeed to allow this behavior or something else I can do to fix this?
 

mistwang

LiteSpeed Staff
#2
LiteSpeed has internal logic to uncompress upstream compressed content if client does not accept gzip compression.
It is a feature, not a bug, and there is no way to turn it off.
 
Top