2009-06-17 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Wed, 17 Jun 2009 18:47:44 +0000 (18:47 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Wed, 17 Jun 2009 18:47:44 +0000 (18:47 -0000)
* WebClient_2_1.cs: Fix BaseAddress and remove dual base[Address|
String] variables.

svn path=/trunk/mcs/; revision=136341

mcs/class/System.Net/System.Net/ChangeLog
mcs/class/System.Net/System.Net/WebClient_2_1.cs

index 46e66589bc5daeb736356a818c133e4bc538c7f7..a7ee36b499614c2cb735d717347252190d55ac76 100644 (file)
@@ -1,3 +1,8 @@
+2009-06-17  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * WebClient_2_1.cs: Fix BaseAddress and remove dual base[Address|
+       String] variables.
+
 2009-06-05  Sebastien Pouliot  <sebastien@ximian.com>
 
        * WebClient_2_1.cs: Make sure *CompletedEventArgs gets called 
index 01f2022e890e9abffeb0d86111c500ee1d97de5f..8e52a547b88119ef85ecba2cd15502cb11941f41 100644 (file)
@@ -44,8 +44,7 @@ namespace System.Net {
 
                WebHeaderCollection headers;
                WebHeaderCollection responseHeaders;
-               Uri baseAddress;
-               string baseString;
+               string baseAddress;
                bool is_busy;
                Encoding encoding = Encoding.UTF8;
                bool allow_read_buffering = true;
@@ -58,28 +57,23 @@ namespace System.Net {
                        // but without adding dependency on System.Windows.dll. GetData is [SecurityCritical]
                        // this makes the default .ctor [SecuritySafeCritical] which would be a problem (inheritance)
                        // but it happens that MS SL2 also has this default .ctor as SSC :-)
-                       baseAddress = new Uri (AppDomain.CurrentDomain.GetData ("xap_uri") as string);
+                       baseAddress = (AppDomain.CurrentDomain.GetData ("xap_uri") as string);
                        locker = new object ();
                }
                
                // Properties
                
                public string BaseAddress {
-                       get {
-                               if (baseString == null) {
-                                       if (baseAddress == null)
-                                               return String.Empty;
-                                       else
-                                               baseString = baseAddress.ToString ();
-                               }
-                               return baseString;
-                       }
-                       
+                       get { return baseAddress; }
                        set {
                                if (String.IsNullOrEmpty (value)) {
-                                       baseAddress = null;
+                                       baseAddress = String.Empty;
                                } else {
-                                       baseAddress = new Uri (value);
+                                       Uri uri = null;
+                                       if (!Uri.TryCreate (value, UriKind.Absolute, out uri))
+                                               throw new ArgumentException ("Invalid URI");
+
+                                       baseAddress = Uri.UnescapeDataString (uri.AbsoluteUri);
                                }
                        }
                }
@@ -483,7 +477,7 @@ namespace System.Net {
                                throw new ArgumentNullException ("address");
 
                        // if the URI is relative then we use our base address URI to make an absolute one
-                       Uri uri = address.IsAbsoluteUri ? address : new Uri (baseAddress, address);
+                       Uri uri = address.IsAbsoluteUri ? address : new Uri (new Uri (baseAddress), address);
 
                        WebRequest request = WebRequest.Create (uri);