Making sure mono_marshal_free is used instead of g_free in mono_string_builder_to_utf8
[mono.git] / mcs / class / System / System.Net / WebHeaderCollection.cs
index c9b7ee2b03da1a363ce89a5706974f77c9f4f7b4..967a4eb0fafacd31913ede4d5ac739008cbf08a0 100644 (file)
@@ -44,13 +44,9 @@ using System.Text;
     
 namespace System.Net 
 {
-#if MOONLIGHT
-       internal class WebHeaderCollection : NameValueCollection, ISerializable {
-#else
        [Serializable]
        [ComVisible(true)]
        public class WebHeaderCollection : NameValueCollection, ISerializable {
-#endif
                [Flags]
                internal enum HeaderInfo
                {
@@ -124,6 +120,14 @@ namespace System.Net
                public WebHeaderCollection ()
                {
                }
+
+
+        internal WebHeaderCollection(WebHeaderCollectionType type)
+        {
+//            m_Type = type;
+//            if (type == WebHeaderCollectionType.HttpWebResponse)
+//                m_CommonHeaders = new string[s_CommonHeaderNames.Length - 1];  // Minus one for the sentinel.
+        }              
                
                protected WebHeaderCollection (SerializationInfo serializationInfo, 
                                               StreamingContext streamingContext)
@@ -181,10 +185,16 @@ namespace System.Net
                                headerValue = headerValue.Trim ();
                        if (!IsHeaderValue (headerValue))
                                throw new ArgumentException ("invalid header value: " + headerValue, "headerValue");
+                       
+                       AddValue (headerName, headerValue);
+               }
+                       
+               internal void AddValue (string headerName, string headerValue)
+               {
                        base.Add (headerName, headerValue);                     
                }
 
-               public override string [] GetValues (string header)
+               internal string [] GetValues_internal (string header, bool split)
                {
                        if (header == null)
                                throw new ArgumentNullException ("header");
@@ -193,11 +203,15 @@ namespace System.Net
                        if (values == null || values.Length == 0)
                                return null;
 
-                       if (IsMultiValue (header)) {
+                       if (split && IsMultiValue (header)) {
                                List<string> separated = null;
                                foreach (var value in values) {
-                                       if (value.IndexOf (',') < 0)
+                                       if (value.IndexOf (',') < 0) {
+                                               if (separated != null)
+                                                       separated.Add (value);
+                                               
                                                continue;
+                                       }
 
                                        if (separated == null) {
                                                separated = new List<string> (values.Length + 1);
@@ -226,6 +240,11 @@ namespace System.Net
                        return values;
                }
 
+               public override string [] GetValues (string header)
+               {
+                       return GetValues_internal (header, true);
+               }
+
                public override string[] GetValues (int index)
                {
                        string[] values = base.GetValues (index);
@@ -333,13 +352,11 @@ namespace System.Net
 
                        return sb.Append("\r\n").ToString();
                }
-#if !TARGET_JVM
                void ISerializable.GetObjectData (SerializationInfo serializationInfo,
                                                  StreamingContext streamingContext)
                {
                        GetObjectData (serializationInfo, streamingContext);
                }
-#endif
                public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
                {
                        int count = base.Count;
@@ -664,7 +681,7 @@ namespace System.Net
                                return;
 
                        if ((info & headerRestriction.Value) != 0)
-                               throw new ArgumentException ("This header must be modified with the appropiate property.");
+                               throw new ArgumentException ("This header must be modified with the appropriate property.");
                }
 
                void CheckHeaderConsistency (HeaderInfo value)