none
ServicePoint/HttpConnection/Http 1.1/Resonse&stream.close internals. Please help RRS feed

  • Question

  • Hi 

    In .net framework 3.5 , http 1.1 i.e persistent connections is used and pipelining is enabled bydefault. Could you please let me know it is neccessary to close stream or connection by calling httpresponse.close or stream.close method to release a connection for another http request to the same internet resourece ? My understanding is even if httpresponse.close or stream.close is not called then too httpconnection i.e. servicepoint should be able to server another concurrent request. Please confirm.

    Wednesday, August 28, 2013 1:10 AM

Answers

  • Hello,

    Thanks for your posting.

    From your description,I think it should be HTTPWebResponse, not  HttpResponse class which is used in ASP.NET applications and whose methods and properties are exposed through ASP.NET's intrinsic Response object.

    If it is true. I think that you should never directly create an instance of the HttpWebResponse class. Instead, use the instance returned by a call to HttpWebRequest.GetResponse. You must call either the Stream.Close or the HttpWebResponse.Close method to close the response and release the connection for reuse. It is not necessary to call both Stream.Close and HttpWebResponse.Close, but doing so does not cause an error.

    In addition, you can refer  this link : http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.aspx

    Hope these help.


    Lilia Gong <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Sunday, September 1, 2013 3:52 PM
    Moderator