Merge remote branch 'upstream/master'
[mono.git] / mcs / class / System / System.Net / WebException.cs
index 86c8067ecc55a1d2bc9ef655e50774fdf0fd8562..1e401660db60d6919439cd45b3ab6450e1c4dcde 100644 (file)
@@ -4,38 +4,40 @@
 // Author:\r
 //   Lawrence Pit (loz@cable.a2000.nl)\r
 //\r
-
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
+\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
 \r
 using System.Runtime.Serialization;\r
 \r
 namespace System.Net \r
 {\r
+#if MOONLIGHT && INSIDE_SYSTEM\r
+       internal class WebException : InvalidOperationException, ISerializable {\r
+#else\r
        [Serializable]\r
-       public class WebException : InvalidOperationException, ISerializable\r
-       {\r
+       public class WebException : InvalidOperationException, ISerializable {\r
+#endif\r
                private WebResponse response;\r
-               private WebExceptionStatus status = WebExceptionStatus.RequestCanceled;\r
-               \r
+               private WebExceptionStatus status = WebExceptionStatus.UnknownError;\r
 \r
                // Constructors\r
                \r
@@ -51,8 +53,6 @@ namespace System.Net
                                        StreamingContext context)\r
                        : base (info, context)\r
                {\r
-                       status = (WebExceptionStatus) info.GetInt32 ("web_status");\r
-                       response = (WebResponse) info.GetValue ("web_response", typeof (WebResponse));\r
                }\r
 \r
                public WebException (string message, Exception innerException)\r
@@ -65,12 +65,18 @@ namespace System.Net
                {\r
                        this.status = status;\r
                }\r
+               \r
+               internal WebException (string message, Exception innerException, WebExceptionStatus status)\r
+                       : base (message, innerException)\r
+               {\r
+                       this.status = status;\r
+               }\r
 \r
                public WebException(string message, \r
                                    Exception innerException,\r
                                    WebExceptionStatus status, \r
                                    WebResponse response)\r
-                       : base (message, innerException)                                    \r
+                       : base (message, innerException)\r
                {\r
                        this.status = status;\r
                        this.response = response;\r
@@ -87,13 +93,17 @@ namespace System.Net
                }\r
                \r
                // Methods\r
-               \r
+#if !TARGET_JVM\r
                void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)\r
                {\r
                        base.GetObjectData (info, context);\r
-                       info.AddValue ("web_status", (int) status, typeof (int));\r
-                       info.AddValue ("web_response", response, typeof (WebResponse));\r
+               }\r
+#endif \r
+\r
+               public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)\r
+               {\r
+                       base.GetObjectData (serializationInfo,\r
+                                           streamingContext);\r
                }\r
        }\r
 }\r
-       \r