iis 7 - How to handle Compressed Request in WCF REST service -


we have wcf rest service hosted on iis 7 .net framework 4.5. client sending data in gzip compressed format request headers:

content-encoding:gzip content-type: application/xml 

but getting bad request server, if request in compressed format. enabled request compression implementation of ihttpmodule filter/modify incoming requests. understanding, failing because wcf uses original content length (that of compressed data) instead of decompressed data. here questions:

is there way can fix content length issues in iis7/.net 4.5? http module implementation given below:

httpapplication.request.filter = new gzipstream(httpapplication.request.filter, compressionmode.decompress)` 

if fixing content length issue not possible @ server side, there way can send original content length client compressed request? client side implementation follows:

using (stream requeststream = servicerequest.getrequeststream()) {    if (usecompression)    {        using (gzipstream zipstream = new gzipstream(requeststream, compressionmode.compress))        {            zipstream.write(bytes, 0, bytes.length);            zipstream.close();            requeststream.close();        }         servicerequest.headers.add("content-encoding", "gzip");    }    else    {        requeststream.write(bytes, 0, bytes.length);        requeststream.close();    } } 

check if can work compression , binary encoder msdn: choosing message encoder


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

java.util.scanner - How to read and add only numbers to array from a text file -

iphone - Three second countdown in cocos2d -