WCF 不支持使用 HTTP 身份验证通过 HTTP 进行请求流传输的原因是什么?
WCF 不支持使用 HTTP 身份验证通过 HTTP 请求流式传输(也称为大数据流式上传)。我的第一个猜测是,这是因为身份验证握手导致流请求向服务器发送两次。但缓冲模式下的大请求也是如此,所以它没有意义。
您可以在自定义 ASP.NET http 处理程序中使用 HTTP 身份验证轻松实现请求流。如果您可以控制客户端,您甚至可以通过执行显式 HTTP HEAD 来预先向服务器进行身份验证,然后重用持久连接来通过 HTTP POST 执行实际的流请求,从而避免“多个请求问题”。
那么有人能想到 WCF 不支持这一点的原因吗? (除了没有时间这样做)
谢谢
WCF does not support request streaming (aka streaming upload of large data) over HTTP with HTTP authentication. My first guess was it is because of authentication handshake causing the streaming request to be send twice to the server. But that is also the case for large request in buffered mode so it doesn't make sense.
You can easily implement request streaming with HTTP authentication in custom ASP.NET http handler. If you have control over the client you can even avoid "multiple requests problem" by doing explicit HTTP HEAD to pre-authenticate to server and then reuse persistent connection to do the actual streaming request with HTTP POST.
So can anybody think of the reason(s) WCF not supporting this? (other than no time to do that)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原因是您必须首先发送整个请求(甚至是流式传输)以获得 HTTP 401 并遵循安全握手,最后再次发送整个请求。因为流式传输应该用于非常大的消息,所以这个过程可能非常慢,并且会在网络上添加不需要的流量,因此微软可能做出了设计决定根本不允许它。
WCF 中未实现 HEAD 请求的技巧。
The reason is that you must first send the whole request (even streamed) to get HTTP 401 and follow security handshake and finally send the whole request again. Because streaming is supposed to be used with very large messages this process can be very slow and add unwanted traffic over the network so MS probably did design decision to not allow it at all.
The trick with HEAD request is not implemented in WCF.