Re: Bug in HttpWebRequest/Response Dispose() implementation?



Well, the problem we discovered was actually in our code running on .NET 2.0
:-(

We will investigate more, but first impression - the problem is still there,
since "using" does not work and GC.Collect does.

Vagif


"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.1f163f10c600e81298d2c6@xxxxxxxxxxxxxxxxxxxxxxx
Vagif Abilov <vagif@xxxxxxxxx> wrote:
I am not in the office right now, but I guess the original code looked
like
this:

HttpWebRequest request = PrepareRequest(...);
using(HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
... do something with response
}

HttpWebRequest is not disposable, so we applied "using" pattern to
HttpWebResponse object only.

While searching for the source of the problem, I found couple of
documents:

http://dturini.blogspot.com/2004/06/on-past-few-days-im-dealing-with-some.html

http://support.microsoft.com/?kbid=831138

Looks like there .NET 1.1 had a problem with release of unmanaged
resources
allocated by HttpResponse. Does .NET 2.0 has the same problem?

Hmm. Glad you've found it. I *suspect* that .NET 2.0 doesn't have the
same problem, given that it was fixed against 1.1 in the hotfix. I
wouldn't like to say for sure though.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too


.



Relevant Pages

  • RE: HTTPS WebRequest and WebResponse
    ... > // Creates an HttpWebRequest for the specified URL. ... > // Displays all the headers present in the response received from the URI. ... > // Obtain a 'Stream' object associated with the response object. ... > StreamReader readStream = new StreamReader(ReceiveStream, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Capturing XML pages from Server
    ... Thanks for your response and glad that it's of assistance. ... Microsoft Online Support ... WE can use the HttpWebRequest to send get/post ... |> Get Secure! ...
    (microsoft.public.dotnet.framework.aspnet)
  • HTTPS WebRequest and WebResponse
    ... // Creates an HttpWebRequest for the specified URL. ... // Displays all the headers present in the response received from the URI. ... // Obtain a 'Stream' object associated with the response object. ... StreamReader readStream = new StreamReader(ReceiveStream, ...
    (microsoft.public.dotnet.languages.csharp)
  • problem WebRequest and WebResponse
    ... I have a problem using HttpWebRequest so I wish somebody can help me. ... HttpWebRequest request = ... WebResponse response = null; ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& ...
    (microsoft.public.dotnet.languages.csharp)
  • Help! HttpWebRequest throwing exceptions
    ... I'm writing a console application and am having a problem with HttpWebRequest ... status code of the returned response header. ... You can see where the problem exception is raised. ...
    (microsoft.public.dotnet.framework.webservices)