if (container != null) {
this.cookieContainer = container;
FillCookies ();
- } else if (webHeaders != null) {
- webHeaders.RemoveInternal ("Set-Cookie");
- webHeaders.RemoveInternal ("Set-Cookie2");
}
}
public string ContentEncoding {
get {
CheckDisposed ();
- return webHeaders ["Content-Encoding"];
+ string h = webHeaders ["Content-Encoding"];
+ return h != null ? h : "";
}
}
}
// Methods
-
+#if !NET_2_0
public override int GetHashCode ()
{
CheckDisposed ();
return base.GetHashCode ();
}
+#endif
public string GetResponseHeader (string headerName)
{
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;
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) {
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)
cookie.Secure = true;
break;
case "VERSION":
- cookie.Version = Int32.Parse (val);
+ try {
+ cookie.Version = (int) UInt32.Parse (val);
+ } catch {}
break;
}
}
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;
}