如何刷新HttpListener响应流? [英] How to flush HttpListener response stream?

查看:156
本文介绍了如何刷新HttpListener响应流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HttpListener为您提供响应流,但调用flush意味着什么(从源代码来看很清楚,因为它实际上什么都不做)。挖掘HTTP API内部显示这是HttpListener本身的限制。

HttpListener gives you response stream, but calling flush means nothing (and from sources it's clear, because it's actually doing nothing). Digging inside HTTP API shows that this is a limitation of HttpListener itself.

任何人都知道如何刷新HttpListener的响应流(可能是反射或额外的P / Invokes) ?

Anyone knows exactly how to flush response stream of HttpListener (may be with reflection or additional P/Invokes)?

更新:如果您没有刷新选项或能够定义缓冲区大小,则无法对任何内容进行http流处理。

Update: You can't http stream anything if you don't have a flush option or ability to define buffer size.

推荐答案

当Transfer-Encoding设置为Chuncked时,Flush仅适用于大多数System.Net命名空间,否则返回整个请求并且同花顺真的什么都不做。至少这是我在使用HttpWebResponse时所经历的。

Flush only works in most of the System.Net namespace when Transfer-Encoding is set to Chuncked, else the whole request is returned and Flush really does nothing. At least this is what I have experienced while working with HttpWebResponse.

这篇关于如何刷新HttpListener响应流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆