Accepting GZip on the server

Topics: Web Api
Oct 6, 2011 at 6:56 PM

Is there a way using a "DelegatingChannel" (or something) to intercept the message, check for the "Content-Encoding" and attempt to GZip.Decompress it?  That way there is an option for clients to pass in GZipped content?

Has anyone attempted this, can I alter the actual request content before any other processing happens?

Oct 6, 2011 at 8:19 PM

Yes, that is certainly one of the things you can do with a message handler.

Pedro Félix has a nice blog [1] on message handlers here.

Henrik

[1] http://pfelix.wordpress.com/2011/08/09/wcf-web-apimessage-handlers/

Coordinator
Oct 6, 2011 at 8:32 PM
Darrel Miller has done this with an operation handler and a custom CompressedContent class. Maybe he will share :•)

Sent from my Windows Phone

From: HenrikN
Sent: 10/6/2011 2:20 PM
To: Glenn Block
Subject: Re: Accepting GZip on the server [wcf:275028]

From: HenrikN

Yes, that is certainly one of the things you can do with a message handler.

Pedro Félix has a nice blog [1] on message handlers here.

Henrik

[1] http://pfelix.wordpress.com/2011/08/09/wcf-web-apimessage-handlers/

Oct 6, 2011 at 8:40 PM

Hopefully he will :)

But I will be working on this now that I know that (it's possible)/(I'm on the right track). Thanks for the quick responses.

Oct 7, 2011 at 12:02 AM

The current operation handler here [1] only handles compressing responses but it should be trivial to add the functionality to decompress requests in a similar way.

 

 

 

[1] http://webapicontrib.codeplex.com/SourceControl/changeset/view/982e23432fd8#source%2fWebApiContrib.OperationHandlers%2fCompressionHandler.cs