// Authors:
// Lawrence Pit (loz@cable.a2000.nl)
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
+// Daniel Nauck (dna(at)mono-project(dot)de)
//
// (c) 2002 Lawrence Pit
// (c) 2003 Ximian, Inc. (http://www.ximian.com)
+// (c) 2008 Daniel Nauck
//
//
}
}
+#if NET_2_0
+ [Obsolete ("Serialization is obsoleted for this type", false)]
+#endif
protected HttpWebResponse (SerializationInfo serializationInfo, StreamingContext streamingContext)
{
SerializationInfo info = serializationInfo;
return webHeaders;
}
}
+
+#if NET_2_0
+ static Exception GetMustImplement ()
+ {
+ return new NotImplementedException ();
+ }
+
+ [MonoTODO]
+ public override bool IsMutuallyAuthenticated
+ {
+ get {
+ throw GetMustImplement ();
+ }
+ }
+#endif
public DateTime LastModified {
get {
void ISerializable.GetObjectData (SerializationInfo serializationInfo,
StreamingContext streamingContext)
+ {
+ GetObjectData (serializationInfo, streamingContext);
+ }
+
+#if NET_2_0
+ protected override
+#endif
+ void GetObjectData (SerializationInfo serializationInfo,
+ StreamingContext streamingContext)
{
SerializationInfo info = serializationInfo;
info.AddValue ("cookieCollection", cookieCollection);
info.AddValue ("version", version);
info.AddValue ("statusCode", statusCode);
- }
-
+ }
// Cleaning up stuff
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 {
case "EXPIRES": // Netscape Style Set-Cookie
if (cookie.Expires != DateTime.MinValue)
break;
- try {
- cookie.Expires = DateTime.ParseExact (val, "r", CultureInfo.InvariantCulture);
- } catch {
- try {
- cookie.Expires = DateTime.ParseExact (val,
- "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'",
- CultureInfo.InvariantCulture);
- } catch {
- cookie.Expires = DateTime.Now.AddDays (1);
- }
- }
+
+ cookie.Expires = TryParseCookieExpires (val);
break;
case "PATH":
cookie.Path = val;
foreach (string cookie_str in cookies)
SetCookie (cookie_str);
}
+
+ string[] cookieExpiresFormats =
+ new string[] { "r",
+ "ddd, dd'-'MMM'-'yyyy HH':'mm':'ss 'GMT'",
+ "ddd, dd'-'MMM'-'yy HH':'mm':'ss 'GMT'" };
+
+ DateTime TryParseCookieExpires (string value)
+ {
+ if (value == null || value.Length == 0)
+ return DateTime.MinValue;
+
+ for (int i = 0; i < cookieExpiresFormats.Length; i++)
+ {
+ try {
+ DateTime cookieExpiresUtc = DateTime.ParseExact (value, cookieExpiresFormats [i], CultureInfo.InvariantCulture);
+
+ //convert UTC/GMT time to local time
+#if NET_2_0
+ cookieExpiresUtc = DateTime.SpecifyKind (cookieExpiresUtc, DateTimeKind.Utc);
+ return 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);
+ return cookieExpiresUtc.Add (localOffset);
+#endif
+ } catch {}
+ }
+
+ //If we can't parse Expires, use cookie as session cookie (expires is DateTime.MinValue)
+ return DateTime.MinValue;
+ }
}
class CookieParser {