Author: dna
Date: 2008-02-09 08:43:40 -0500 (Sat, 09 Feb 2008)
New Revision: 95334

Modified:
   trunk/mcs/class/System/System.Net/ChangeLog
   trunk/mcs/class/System/System.Net/HttpWebResponse.cs
Log:
2008-02-09  Daniel Nauck  <[EMAIL PROTECTED]>

        * HttpWebResponse.cs: convert UTC/GMT Expires DateTime from a cookie
        into local time, also set the HttpOnly property if available.



Modified: trunk/mcs/class/System/System.Net/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Net/ChangeLog 2008-02-09 13:37:15 UTC (rev 
95333)
+++ trunk/mcs/class/System/System.Net/ChangeLog 2008-02-09 13:43:40 UTC (rev 
95334)
@@ -1,5 +1,10 @@
 2008-02-09  Daniel Nauck  <[EMAIL PROTECTED]>
 
+       * HttpWebResponse.cs: convert UTC/GMT Expires DateTime from a cookie
+       into local time, also set the HttpOnly property if available.
+
+2008-02-09  Daniel Nauck  <[EMAIL PROTECTED]>
+
        * Cookie.cs: implemented HttpOnly
 
 2008-01-27  Gert Driesen  <[EMAIL PROTECTED]>

Modified: trunk/mcs/class/System/System.Net/HttpWebResponse.cs
===================================================================
--- trunk/mcs/class/System/System.Net/HttpWebResponse.cs        2008-02-09 
13:37:15 UTC (rev 95333)
+++ trunk/mcs/class/System/System.Net/HttpWebResponse.cs        2008-02-09 
13:43:40 UTC (rev 95334)
@@ -4,6 +4,7 @@
 // Authors:
 //     Lawrence Pit ([EMAIL PROTECTED])
 //     Gonzalo Paniagua Javier ([EMAIL PROTECTED])
+//      Daniel Nauck    (dna(at)mono-project(dot)de)
 //
 // (c) 2002 Lawrence Pit
 // (c) 2003 Ximian, Inc. (http://www.ximian.com)
@@ -396,6 +397,11 @@
                                        if (cookie.Domain == "")
                                                cookie.Domain = val;
                                        break;
+#if NET_2_0
+                               case "HTTPONLY":
+                                       cookie.HttpOnly = true;
+                                       break;
+#endif
                                case "MAX-AGE": // RFC Style Set-Cookie2
                                        if (cookie.Expires == 
DateTime.MinValue) {
                                                try {
@@ -406,17 +412,28 @@
                                case "EXPIRES": // Netscape Style Set-Cookie
                                        if (cookie.Expires != DateTime.MinValue)
                                                break;
+
+                                       //If no Expires is set, use cookie as 
session cookie (expires is DateTime.MinValue)
+                                       DateTime cookieExpiresUtc = 
DateTime.MinValue;
                                        try {
-                                               cookie.Expires = 
DateTime.ParseExact (val, "r", CultureInfo.InvariantCulture);
+                                               cookieExpiresUtc = 
DateTime.ParseExact (val, "r", CultureInfo.InvariantCulture);
                                        } catch {
                                                try { 
-                                               cookie.Expires = 
DateTime.ParseExact (val,
+                                               cookieExpiresUtc = 
DateTime.ParseExact (val,
                                                                "ddd, 
dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'",
                                                                
CultureInfo.InvariantCulture);
-                                               } catch {
-                                                       cookie.Expires = 
DateTime.Now.AddDays (1);
-                                               }
+                                               } catch {}
                                        }
+
+                                       //convert UTC/GMT time to local time
+#if NET_2_0
+                                       cookieExpiresUtc = DateTime.SpecifyKind 
(cookieExpiresUtc, DateTimeKind.Utc);
+                                       cookie.Expires = 
TimeZone.CurrentTimeZone.ToLocalTime (cookieExpiresUtc);
+#else
+                                       //DateTime.Kind is only available on 
.NET 2.0, so do some calculation
+                                       TimeSpan localOffset = 
TimeZone.CurrentTimeZone.GetUtcOffset (cookieExpiresUtc.Date);
+                                       cookie.Expires = cookieExpiresUtc.Add 
(localOffset);
+#endif
                                        break;
                                case "PATH":
                                        cookie.Path = val;

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to