tag:blogger.com,1999:blog-2889416825250254881.post3836226464655625613..comments2024-01-27T11:41:32.146+00:00Comments on Byte Rot: Beware of undisposed or unconsumed HttpResponseMessagealiostadhttp://www.blogger.com/profile/05695786967974402749noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-2889416825250254881.post-57742736824748151502014-01-13T09:25:45.002+00:002014-01-13T09:25:45.002+00:00Then I am not surprised. As Tratcher said, only co...Then I am not surprised. As Tratcher said, only content (and its stream) requires disposing so if it has no content then all headers are read and consumed already.aliostadhttps://www.blogger.com/profile/05695786967974402749noreply@blogger.comtag:blogger.com,1999:blog-2889416825250254881.post-84223065515131653252014-01-13T03:03:34.421+00:002014-01-13T03:03:34.421+00:00I just tried your repro and I was able to see the ...I just tried your repro and I was able to see the leak. However, if I changed the URI to point to my own Web API on localhost that returned 304 and no content then I do not get the leak. Very strange.Darrel Millerhttps://www.blogger.com/profile/14930698586926486164noreply@blogger.comtag:blogger.com,1999:blog-2889416825250254881.post-91904465323073346362014-01-12T14:30:01.180+00:002014-01-12T14:30:01.180+00:00Did you use my repro? Well, what needs disposing i...Did you use my repro? Well, what needs disposing is actually content as Tratcher responded here https://aspnetwebstack.codeplex.com/discussions/461495aliostadhttps://www.blogger.com/profile/05695786967974402749noreply@blogger.comtag:blogger.com,1999:blog-2889416825250254881.post-16781122634413082612014-01-11T21:11:22.333+00:002014-01-11T21:11:22.333+00:00There is something else going on. HttpWebResponse...There is something else going on. HttpWebResponse checks the content-length in its constructor and calls CallDone on the connect stream. I was able to run a loop of 10000 requests against an endpoint with no-content and saw no leak. As soon as I returned 1 byte from the response and I was actually using ResponseHeadersRead then I did see a leak. You do make a good point thought that if you are replacing requests or responses in message handlers then it is important to ensure that any body that is being passed is consumed. I'm puzzled as to why you are seeing a leak when the content length is zero though.<br />Darrel Millerhttps://www.blogger.com/profile/14930698586926486164noreply@blogger.com