WebResponse.GetResponseStream()是否可以返回null? [英] Can WebResponse.GetResponseStream() return a null?

查看:153
本文介绍了WebResponse.GetResponseStream()是否可以返回null?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个菜鸟问题,但是只是想知道 GetResponseStream()是否在任何情况下都可以返回null?

i know its a noob question, but just wanted to know whether GetResponseStream() can return null in any case?

推荐答案

好吧,这取决于具体的子类-但我从未见过这样做的子类,并且没有记录有效的返回值。我从未见过为防御性检查而编写的任何代码,也没想到。并不是说这样的代码不存在,但我认为没有必要。

Well, it's sort of up to the concrete subclass - but I've never seen any subclass which does so, and it's not documented as a valid return value. I've never seen any code written to defensively check for this, and I wouldn't expect to. That's not to say such code doesn't exist, but I don't think it's necessary.

如果响应中没有内容(但响应成功),我希望任何好的实现都能返回空流。

If there's no content in the response (but the response was successful) I'd expect any good implementation to return an empty stream.

这篇关于WebResponse.GetResponseStream()是否可以返回null?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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