2009-04-13 Gonzalo Paniagua Javier <gonzalo@novell.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 13 Apr 2009 16:28:20 +0000 (16:28 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Mon, 13 Apr 2009 16:28:20 +0000 (16:28 -0000)
* HttpUtility.cs: the collection returned from ParseQueryString knows
how to convert the key/value pairs to a string.

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

mcs/class/System.Web/System.Web/ChangeLog
mcs/class/System.Web/System.Web/HttpUtility.cs

index 81cde1cc24292c77fa15a8a8ea7c27e8abad9948..5ee2ef03e5cd7f827362b348a510a63f93add344 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-13 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+       * HttpUtility.cs: the collection returned from ParseQueryString knows
+       how to convert the key/value pairs to a string.
+
 2009-04-10 Gonzalo Paniagua Javier <gonzalo@novell.com>
 
        * HttpResponseStream.cs: use the unsafe version when copying buffers.
index 82111fff5b8b446e21c921b0c22e604c72dd4c7d..8c1e2440f6091b42fae9e145e249cca915cb609c 100644 (file)
@@ -1033,6 +1033,23 @@ namespace System.Web {
 #endif
 
 #if NET_2_0
+               class HttpQSCollection : NameValueCollection {
+                       public override string ToString ()
+                       {
+                               int count = Count;
+                               if (count == 0)
+                                       return "";
+                               StringBuilder sb = new StringBuilder ();
+                               string [] keys = AllKeys;
+                               for (int i = 0; i < count; i++) {
+                                       sb.AppendFormat ("{0}={1}&", keys [i], this [keys [i]]);
+                               }
+                               if (sb.Length > 0)
+                                       sb.Length--;
+                               return sb.ToString ();
+                       }
+               }
+
                public static NameValueCollection ParseQueryString (string query)
                {
                        return ParseQueryString (query, Encoding.UTF8);
@@ -1049,7 +1066,7 @@ namespace System.Web {
                        if (query[0] == '?')
                                query = query.Substring (1);
                                
-                       NameValueCollection result = new NameValueCollection ();
+                       NameValueCollection result = new HttpQSCollection ();
                        ParseQueryString (query, encoding, result);
                        return result;
                }