Can WebResponse.GetResponseStream() return a null?

前端 未结 2 1153
旧巷少年郎
旧巷少年郎 2021-01-17 11:29

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

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-17 11:39

    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.

提交回复
热议问题