访问自定义 WCF MessageEncoder 中的请求 HTTP 标头

发布于 2024-08-16 06:13:29 字数 434 浏览 4 评论 0原文

有谁知道如何在 MessageEncoder.ReadMessage 方法中访问请求 HTTP 标头? 看来 WCF 在调用 ReadMessage 方法时已经“知道”请求标头,至少是 Content-Type 和 Content-Length,但我无法访问 Content-Encoding 标头。

基本上,我正在尝试将 gzip de/compression 用于 WCF 服务 (http: //msdn.microsoft.com/en-us/library/ms751458.aspx)并想检查传入请求是否需要解压缩。为此,我想检查 Content-Encoding 标头,但无法弄清楚从哪里获取它。 有什么想法吗?

谢谢!

Does anyone know how to get access to request HTTP headers within MessageEncoder.ReadMessage method?
It seems that WCF already "knows" request headers at the point of invoking ReadMessage method, at least Content-Type and Content-Length but I cannot get the access to the Content-Encoding header.

Basically, I'm trying to utilize gzip de/compression for WCF service (http://msdn.microsoft.com/en-us/library/ms751458.aspx) and would like to check if decompression is necessary for incoming request. To do that I'd like to check Content-Encoding header but cannot figure out where to get it.
Any ideas?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

再可℃爱ぅ一点好了 2024-08-23 06:13:29

这是一个答案我在另一个线程中给出了解释您需要如何通过与 MessageEncoder 耦合的另一个 IOperationBehavior 中的 WebOperationContext 来操作标头。

Here's an answer I gave in another thread which explains how you would need to manipulate the headers via the WebOperationContext in another IOperationBehavior which is coupled with the MessageEncoder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文