Merge pull request #2020 from tomjepp/master
[mono.git] / mcs / class / System / System.Net / WebResponse.cs
index ac5fbc2546597e163360737d2ee04792777df5b0..f59b24fc1c38cfbe8e491a3db3fc8cf81f7d000a 100644 (file)
@@ -33,8 +33,7 @@ using System.Runtime.Serialization;
 namespace System.Net \r
 {\r
        [Serializable]\r
-       public abstract class WebResponse : MarshalByRefObject, ISerializable, IDisposable\r
-       {\r
+       public abstract class WebResponse : MarshalByRefObject, ISerializable, IDisposable {\r
                // Constructors\r
                \r
                protected WebResponse () { }\r
@@ -60,7 +59,6 @@ namespace System.Net
                        get { throw new NotSupportedException (); }\r
                }\r
 \r
-#if NET_2_0\r
                static Exception GetMustImplement ()\r
                {\r
                        return new NotImplementedException ();\r
@@ -70,7 +68,9 @@ namespace System.Net
                public virtual bool IsFromCache\r
                {\r
                        get {\r
-                               throw GetMustImplement ();\r
+                               return false;\r
+                               // Better to return false than to kill the application\r
+                               // throw GetMustImplement ();\r
                        }\r
                }\r
                \r
@@ -81,12 +81,18 @@ namespace System.Net
                                throw GetMustImplement ();\r
                        }\r
                }\r
-#endif\r
                \r
                public virtual Uri ResponseUri {                \r
                        get { throw new NotSupportedException (); }\r
                }               \r
 \r
+               public virtual bool SupportsHeaders {\r
+                       get {\r
+                               // The managed stack always returns this as true, it is only\r
+                               // the Silverlight stack that does not support this.\r
+                               return true;\r
+                       }\r
+               }\r
                // Methods\r
                \r
                public virtual void Close()\r
@@ -98,13 +104,15 @@ namespace System.Net
                {\r
                        throw new NotSupportedException ();\r
                }\r
-#if TARGET_JVM //enable overrides for extenders\r
-               public virtual void Dispose()\r
-#else\r
-               void IDisposable.Dispose()\r
-#endif\r
+               public void Dispose ()\r
+               {\r
+                       Dispose (true);\r
+               }\r
+               \r
+               protected virtual void Dispose (bool disposing)\r
                {\r
-                       Close ();\r
+                       if (disposing)\r
+                               Close ();\r
                }\r
 \r
                void ISerializable.GetObjectData\r
@@ -114,12 +122,10 @@ namespace System.Net
                        throw new NotSupportedException ();\r
                }\r
 \r
-#if NET_2_0\r
                [MonoTODO]\r
                protected virtual void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
                {\r
                        throw GetMustImplement ();\r
                }\r
-#endif\r
        }\r
 }\r