Applying Content-Encoding headers to a request is tricky subject. While it's part of the HTTP specification, there's no way to determine if a server supports it ahead of time since no communication occurs before a request. Still if the server/client are controlled, request encoding can come in handy for certain scenarios. One such scenario that's becoming more common is uploading log data from a mobile application.

If you use Fiddler to debug your HTTP, you might have spotted that there's no way to compress the request body. Fortunately, since Fiddler is so extensible, adding support is easy.

First up, open the CustomRules script by selecting "Customize Rules..." from the Edit menu (or by pressing CTRL+R).

Now paste the following code just before the lines adding RulesStringValue entries for each browser (around Line 50 of an uncustomised script):

// Request GZip encoding<br />
public static RulesOption("Apply GZIP Encoding to Request")
var m_gzipRequest: boolean = false;

Next, paste the following code at the end of OnBeforeRequest(), right after the "if (m_AlwaysFresh && ...)" block (around Line 210):

if (m_gzipRequest && oSession.requestBodyBytes != null &&
    oSession.requestBodyBytes.length > 0 && !oSession.oRequest.headers["Content-Encoding"])
{
    oSession.requestBodyBytes = Utilities.GzipCompress(oSession.requestBodyBytes);
    oSession.oRequest.headers["Content-Length"] = oSession.requestBodyBytes.Length.ToString();
    oSession.oRequest.headers["Content-Encoding"] = "gzip";
}

Now whenever you want request bodies to be compressed, check "Apply GZIP Encoding to Request" from the Rules menu. Don't forget to turn it off again!