* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System / System.Net / HttpWebResponse.cs
index 4868bd1caa9eb7e362032b78d4da07515d098166..d86e3fd5065d12ac0d474a5644b30f17304221e0 100644 (file)
@@ -71,9 +71,6 @@ namespace System.Net
                        if (container != null) {
                                this.cookieContainer = container;
                                FillCookies ();
-                       } else if (webHeaders != null) {
-                               webHeaders.RemoveInternal ("Set-Cookie");
-                               webHeaders.RemoveInternal ("Set-Cookie2");
                        }
                }
 
@@ -118,7 +115,8 @@ namespace System.Net
                public string ContentEncoding {
                        get { 
                                CheckDisposed ();
-                               return webHeaders ["Content-Encoding"];
+                               string h = webHeaders ["Content-Encoding"];
+                               return h != null ? h : "";
                        }
                }
                
@@ -224,12 +222,13 @@ namespace System.Net
                }
 
                // Methods
-               
+#if !NET_2_0
                public override int GetHashCode ()
                {
                        CheckDisposed ();
                        return base.GetHashCode ();
                }
+#endif
                
                public string GetResponseHeader (string headerName)
                {
@@ -288,8 +287,11 @@ namespace System.Net
                        Dispose (true);
                        GC.SuppressFinalize (this);  
                }
-               
-               protected virtual void Dispose (bool disposing) 
+
+#if !NET_2_0
+               protected virtual
+#endif
+               void Dispose (bool disposing) 
                {
                        if (this.disposed)
                                return;
@@ -343,7 +345,7 @@ namespace System.Net
                        CookieParser parser = new CookieParser (header);
 
                        while (parser.GetNextNameValue (out name, out val)) {
-                               if (name == null || name == "")
+                               if ((name == null || name == "") && cookie == null)
                                        continue;
 
                                if (cookie == null) {
@@ -369,8 +371,11 @@ namespace System.Net
                                                cookie.Domain = val;
                                        break;
                                case "MAX-AGE": // RFC Style Set-Cookie2
-                                       if (cookie.Expires == DateTime.MinValue)
-                                               cookie.Expires = cookie.TimeStamp.AddSeconds (Int32.Parse (val));
+                                       if (cookie.Expires == DateTime.MinValue) {
+                                               try {
+                                               cookie.Expires = cookie.TimeStamp.AddSeconds (UInt32.Parse (val));
+                                               } catch {}
+                                       }
                                        break;
                                case "EXPIRES": // Netscape Style Set-Cookie
                                        if (cookie.Expires != DateTime.MinValue)
@@ -398,7 +403,9 @@ namespace System.Net
                                        cookie.Secure = true;
                                        break;
                                case "VERSION":
-                                       cookie.Version = Int32.Parse (val);
+                                       try {
+                                               cookie.Version = (int) UInt32.Parse (val);
+                                       } catch {}
                                        break;
                                }
                        }
@@ -448,13 +455,14 @@ namespace System.Net
                                return false;
 
                        name = GetCookieName ();
-                       if (header [pos] == '=') {
+                       if (pos < header.Length && header [pos] == '=') {
                                pos++;
                                val = GetCookieValue ();
-                               if (pos < length && header [pos] == ';')
-                                       pos++;
                        }
 
+                       if (pos < length && header [pos] == ';')
+                               pos++;
+
                        return true;
                }