IIS 7 and Above
Can I change the content of an incoming HTTP request using a HTTP Mod...
Last post Feb 20, 2014 06:20 AM by SenneVL
Nov 28, 2013 02:53 AM|Nitramk|LINK
I'm trying to extend my REST service (built using WCF/webHttpBinding) so that clients can upload gzipped data. I'm not sure what the best way to accomplish this but I thought it would be fairly easy by adding a HTTP module which will decompress the data
if Content-Encoding for the incoming request is set to gzip.
So I created an class deriving from IHttpModule with the following implementation:
private void OnBeginRequest(object sender, EventArgs e)
var app = (HttpApplication) sender;
var context = app.Context;
var contentEncoding = context.Request.Headers["Content-Encoding"];
if (contentEncoding == "gzip")
// some debug code:
var decompressedStream = new GZipStream(context.Request.InputStream, CompressionMode.Decompress);
var memoryStream = new MemoryStream();
var streamReader = new StreamReader(memoryStream);
string msg = streamReader.ReadToEnd();
app.Request.Filter = //new TestFilterStream(app.Request.Filter);
The issue I'm seeing is that the GZipStream decompression is never actually performed. I've confirmed that the incoming data is in fact gzip'd (the msg-variable contains the proper data). I've also tried creating my own stream class (TestFilterStream) above
and assign that to app.Request.Filter and I've confirmed that no members on the stream class is actually called by ASP.NET. So it seems like while it's possible to specify a filter, that filter isn't actually used.
Isn't HttpApplication.Request.Filter actually used?
Feb 20, 2014 06:20 AM|SenneVL|LINK
as far as I know, IIS has everything in place to do gzip deflate!