2004-01-27 Nick Drochak <ndrochak@ieee.org>
[mono.git] / mcs / class / System / System.Net / HttpWebResponse.cs
index bb4393d9e419c1aa91bf1830c15284f978ae46e6..60bf0a84ee09b708f8cf6c4cf1394de6dc0cca51 100644 (file)
@@ -31,7 +31,7 @@ namespace System.Net
                string contentType;
 
                bool disposed = false;
-               WebConnectionStream stream;
+               Stream stream;
                
                // Constructors
                
@@ -216,6 +216,8 @@ namespace System.Net
                public override Stream GetResponseStream ()
                {
                        CheckDisposed ();
+                       if (stream == null)
+                               return Stream.Null;  
                        if (0 == String.Compare (method, "HEAD", true)) // see par 4.3 & 9.4
                                return Stream.Null;  
 
@@ -270,8 +272,15 @@ namespace System.Net
                        // release unmanaged resources
                        Stream st = stream;
                        stream = null;
-                       if (st != null)
+                       if (st != null) {
+                               WebConnectionStream wce = st as WebConnectionStream;
+                               if (wce != null) {
+                                       try {
+                                               wce.ReadAll ();
+                                       } catch {}
+                               }
                                st.Close ();
+                       }
                }
                
                private void CheckDisposed ()