I'm getting the response from an HttpWebRequest (using a modified version Jeff Richter's CCR wrappers), then inspecting a few of the headers in order to decide whether or not to continue the download. Sometimes I might not want to continue, so I consequently issue response.Close and request.Abort. Is it necessary to issue GetResponseStream then to close the stream, or is this implicit when one calls response.Close?
After issuing GetResponse, the docs state:
You must call the Close method to close the stream and release the connection. Failure to do so may cause your application to run out of connections.
So does this mean that once we have a response, then it is obligatory to get the stream and close it?
We're seeing some fairly strange issues where hung downloads are eventually swamping the system. This seems like the strongest candidate for a resource leak, but wonder if anyone else has experience with this issue.
As an aside: is it safe to GetResponseStream twice in the assumption that it is the same stream?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…