diff -Nur src\IXmlRpcProxy.cs src.new\IXmlRpcProxy.cs --- src\IXmlRpcProxy.cs Tue Jul 11 09:13:38 2006 +++ src.new\IXmlRpcProxy.cs Sun Nov 25 17:16:51 2007 @@ -77,6 +77,8 @@ string Url { get; set; } bool UseIndentation { get; set; } + + bool EnableCompression { get; set;} bool UseIntTag { get; set; } diff -Nur src\XmlRpcClientProtocol.cs src.new\XmlRpcClientProtocol.cs --- src\XmlRpcClientProtocol.cs Wed Aug 09 08:23:20 2006 +++ src.new\XmlRpcClientProtocol.cs Sun Nov 25 20:43:18 2007 @@ -57,6 +57,9 @@ private bool _useIntTag = false; private Encoding _xmlEncoding = null; private string _xmlRpcMethod = null; + /* GZip support */ + private bool _enableCompression = false; + #if (!COMPACT_FRAMEWORK) private X509CertificateCollection _clientCertificates @@ -176,6 +179,10 @@ deserStream.Flush(); deserStream.Position = 0; } + + /* GZip support */ + deserStream = DecompressStream(webResp, deserStream); + /* End Gzip Support */ try { XmlRpcResponse resp = ReadResponse(req, webResp, deserStream, null); @@ -236,6 +243,12 @@ get { return _headers; } } + public bool EnableCompression + { + get { return _enableCompression; } + set { _enableCompression = value; } + } + #if (!COMPACT_FRAMEWORK) public bool Expect100Continue { @@ -357,6 +370,12 @@ webReq.PreAuthenticate = PreAuthenticate; // Compact Framework sets this to false by default (webReq as HttpWebRequest).AllowWriteStreamBuffering = true; + + /* GZip Compression Support */ + if (_enableCompression) + webReq.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate"); + else + webReq.Headers.Remove(HttpRequestHeader.AcceptEncoding); } private void SetRequestHeaders( @@ -414,6 +433,8 @@ Type retType = returnType; if (retType == null) retType = req.mi.ReturnType; + + XmlRpcResponse xmlRpcResp = serializer.DeserializeResponse(respStm, retType); return xmlRpcResp; @@ -757,6 +778,11 @@ responseStream)); responseStream.Position = 0; } + + /*GZip support */ + responseStream = DecompressStream(webResp, responseStream); + /* End of GZip support */ + XmlRpcResponse resp = ReadResponse(clientResult.XmlRpcRequest, webResp, responseStream, returnType); reto = resp.retVal; @@ -896,6 +922,21 @@ } return ret; } + + /* GZip support */ + protected Stream DecompressStream(WebResponse webResp, Stream respStream) + { + Stream decodedStream; + + if (((HttpWebResponse)webResp).ContentEncoding.ToLower().Contains("gzip")) + decodedStream = new System.IO.Compression.GZipStream(respStream, System.IO.Compression.CompressionMode.Decompress); + else if (((HttpWebResponse)webResp).ContentEncoding.ToLower().Contains("deflate")) + decodedStream = new System.IO.Compression.DeflateStream(respStream, System.IO.Compression.CompressionMode.Decompress); + else + decodedStream = respStream; + + return decodedStream; + } protected virtual WebResponse GetWebResponse(WebRequest request, IAsyncResult result)