我有大量的数据(〜100k),我的C#应用程序发送到我的Apache服务器,安装了mod_gzip.我试图使用System.IO.Compression.GZipStream gzip数据.
PHP收到原始的gzip压缩数据,所以Apache并不像我所期望的那样解压缩它.我错过了什么吗?
System.Net.WebRequest req = WebRequest.Create(this.Url);
req.Method = this.Method; // "post"
req.Timeout = this.Timeout;
req.ContentType = "application/x-www-form-urlencoded";
req.Headers.Add("Content-Encoding: gzip");
System.IO.Stream reqStream = req.GetRequestStream();
GZipStream gz = new GZipStream(reqStream, CompressionMode.Compress);
System.IO.StreamWriter sw = new System.IO.StreamWriter(gz, Encoding.ASCII);
sw.Write( large_amount_of_data );
sw.Close();
gz.Close();
reqStream.Close()
System.Net.WebResponse resp = req.GetResponse();
// (handle response...)
我不完全确定“Content-Encoding:gzip”适用于客户端提供的标题.