2003-07-01 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System / System.Net / HttpWebResponse.cs
index 219a4d7418d0e55a930c5c255a2221d62367265f..bb4393d9e419c1aa91bf1830c15284f978ae46e6 100644 (file)
@@ -22,12 +22,11 @@ namespace System.Net
        {
                Uri uri;
                WebHeaderCollection webHeaders;
-               CookieCollection cookieCollection = null;
+               CookieCollection cookieCollection;
                string method;
                Version version;
                HttpStatusCode statusCode;
                string statusDescription;
-               bool chunked;
                long contentLength = -1;
                string contentType;
 
@@ -36,7 +35,7 @@ namespace System.Net
                
                // Constructors
                
-               internal HttpWebResponse (Uri uri, string method, WebConnectionData data)
+               internal HttpWebResponse (Uri uri, string method, WebConnectionData data, bool cookiesSet)
                {
                        this.uri = uri;
                        this.method = method;
@@ -45,22 +44,26 @@ namespace System.Net
                        statusCode = (HttpStatusCode) data.StatusCode;
                        statusDescription = data.StatusDescription;
                        stream = data.stream;
-                       FillCookies ();
+                       if (cookiesSet) {
+                               FillCookies ();
+                       } else if (webHeaders != null) {
+                               webHeaders.RemoveInternal ("Set-Cookie");
+                               webHeaders.RemoveInternal ("Set-Cookie2");
+                       }
                }
 
-               [MonoTODO("Check this out and update if needed")] //Gon
                protected HttpWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext)
                {
-                       uri = (Uri) serializationInfo.GetValue ("uri", typeof (Uri));
-                       webHeaders = (WebHeaderCollection) serializationInfo.GetValue ("webHeaders",
-                                                                                       typeof (WebHeaderCollection));
-                       cookieCollection = (CookieCollection) serializationInfo.GetValue ("cookieCollection",
-                                                                                          typeof (CookieCollection));
-                       method = serializationInfo.GetString ("method");
-                       version = (Version) serializationInfo.GetValue ("version", typeof (Version));
-                       statusCode = (HttpStatusCode) serializationInfo.GetValue ("statusCode", typeof (HttpStatusCode));
-                       statusDescription = serializationInfo.GetString ("statusDescription");
-                       chunked = serializationInfo.GetBoolean ("chunked");
+                       SerializationInfo info = serializationInfo;
+
+                       uri = (Uri) info.GetValue ("uri", typeof (Uri));
+                       contentLength = info.GetInt64 ("contentLength");
+                       contentType = info.GetString ("contentType");
+                       method = info.GetString ("method");
+                       statusDescription = info.GetString ("statusDescription");
+                       cookieCollection = (CookieCollection) info.GetValue ("cookieCollection", typeof (CookieCollection));
+                       version = (Version) info.GetValue ("version", typeof (Version));
+                       statusCode = (HttpStatusCode) info.GetValue ("statusCode", typeof (HttpStatusCode));
                }
                
                // Properties
@@ -222,15 +225,16 @@ namespace System.Net
                void ISerializable.GetObjectData (SerializationInfo serializationInfo,
                                                  StreamingContext streamingContext)
                {
-                       CheckDisposed ();
-                       serializationInfo.AddValue ("uri", uri);
-                       serializationInfo.AddValue ("webHeaders", webHeaders);
-                       serializationInfo.AddValue ("cookieCollection", cookieCollection);
-                       serializationInfo.AddValue ("method", method);
-                       serializationInfo.AddValue ("version", version);
-                       serializationInfo.AddValue ("statusCode", statusCode);
-                       serializationInfo.AddValue ("statusDescription", statusDescription);
-                       serializationInfo.AddValue ("chunked", chunked);
+                       SerializationInfo info = serializationInfo;
+
+                       info.AddValue ("uri", uri);
+                       info.AddValue ("contentLength", contentLength);
+                       info.AddValue ("contentType", contentType);
+                       info.AddValue ("method", method);
+                       info.AddValue ("statusDescription", statusDescription);
+                       info.AddValue ("cookieCollection", cookieCollection);
+                       info.AddValue ("version", version);
+                       info.AddValue ("statusCode", statusCode);
                }