使用ASP.NET核心响应时压缩。
当使用响应。BodyWriter
从ASP.NET Core Web API端点输出JSON属性时,似乎忽略了配置的压缩方法。
使用推荐的services.AddresponSecompression
和app.useresseponsecompression
在startup.cs中启用压缩。适当的中间件。
但是,使用pipewriter
写入输出的方法似乎完全忽略了这些设置。
当然,我们可以直接将压缩数据写入响应。所有这些已经由ASP.NET在某个地方完成,因此理想情况下,我想避免自己重新实现所有这些。
是否有标准方法将正确的压缩应用于Bobswriter
管道?
When using the Response.BodyWriter
property to output JSON from a ASP.NET Core Web API endpoint, it seems the configured compression method is ignored.
Compression is enabled using the recommended services.AddResponseCompression
and app.UseResponseCompression
calls in Startup.cs, and indeed this works for normal endpoints that return object instances that are later serialized by the appropriate middleware.
However, using the PipeWriter
method to write output seems to ignore these settings completely.
Of course, we can write compressed data to the Response.BodyWriter
pipe directly, but this appears to involve determining the best compression method to use, setting up a Brotli or Gzip writer, and sending chunks through that - all of this is already done by ASP.NET somewhere, so ideally I'd like to avoid re-implementing all this myself.
Is there a standard way to apply the correct compression to the BodyWriter
pipe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论