访问自定义 WCF MessageEncoder 中的请求 HTTP 标头
有谁知道如何在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个答案我在另一个线程中给出了解释您需要如何通过与
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 anotherIOperationBehavior
which is coupled with theMessageEncoder
.