Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将HttpResponse.ContentEncoding设置为GZIP_C#_.net_Iis_Encoding - Fatal编程技术网

C# 将HttpResponse.ContentEncoding设置为GZIP

C# 将HttpResponse.ContentEncoding设置为GZIP,c#,.net,iis,encoding,C#,.net,Iis,Encoding,我有一个小的IHttpModule,它正在从另一台服务器读取POST请求并将其转发。来自远程服务器的响应具有标头 Content-Encoding: gzip 如何在返回给调用者的HttpResponse中指定这一点内容编码被定义为文本编码类型,因此它需要一种文本编码,如UTF8 context.Response.ContentEncoding = ???; 我是否应该忽略这一点并手动设置标题?如果修改响应,则应该解码并读取内容、gzip检索值并在响应中添加标题 //Code for gzi

我有一个小的
IHttpModule
,它正在从另一台服务器读取
POST
请求并将其转发。来自远程服务器的响应具有标头

Content-Encoding: gzip
如何在返回给调用者的
HttpResponse
中指定这一点<代码>内容编码被定义为文本编码类型,因此它需要一种文本编码,如UTF8

context.Response.ContentEncoding = ???;

我是否应该忽略这一点并手动设置标题?

如果修改响应,则应该解码并读取内容、gzip检索值并在响应中添加标题

//Code for gzip the content and add header
context.Response.Filter = new System.IO.Compression.GZipStream(
                context.Response.Filter, 
                System.IO.Compression.CompressionMode.Compress);
context.Response.AppendHeader("Content-Encoding", "gzip");
如果在没有任何改变的情况下传递响应,则无需做任何事情