/// <exception cref="Apache.Http.Cookie.MalformedCookieException"></exception> public override void Validate(Apache.Http.Cookie.Cookie cookie, CookieOrigin origin ) { Args.NotNull(cookie, "Cookie"); if (cookie.GetVersion() < 0) { throw new CookieRestrictionViolationException("Cookie version may not be negative" ); } }
public virtual bool Match(Apache.Http.Cookie.Cookie cookie, CookieOrigin origin) { Args.NotNull(cookie, "Cookie"); Args.NotNull(origin, "Cookie origin"); if (cookie.GetVersion() > 0) { if (cookie is SetCookie2) { return(GetStrict().Match(cookie, origin)); } else { return(GetObsoleteStrict().Match(cookie, origin)); } } else { return(GetCompat().Match(cookie, origin)); } }
/// <exception cref="Apache.Http.Cookie.MalformedCookieException"></exception> public virtual void Validate(Apache.Http.Cookie.Cookie cookie, CookieOrigin origin ) { Args.NotNull(cookie, "Cookie"); Args.NotNull(origin, "Cookie origin"); if (cookie.GetVersion() > 0) { if (cookie is SetCookie2) { GetStrict().Validate(cookie, origin); } else { GetObsoleteStrict().Validate(cookie, origin); } } else { GetCompat().Validate(cookie, origin); } }
public override IList<Header> FormatCookies(IList<Apache.Http.Cookie.Cookie> cookies ) { Args.NotEmpty(cookies, "List of cookies"); CharArrayBuffer buffer = new CharArrayBuffer(20 * cookies.Count); buffer.Append(SM.Cookie); buffer.Append(": "); for (int i = 0; i < cookies.Count; i++) { Apache.Http.Cookie.Cookie cookie = cookies[i]; if (i > 0) { buffer.Append("; "); } string cookieName = cookie.GetName(); string cookieValue = cookie.GetValue(); if (cookie.GetVersion() > 0 && !IsQuoteEnclosed(cookieValue)) { BasicHeaderValueFormatter.Instance.FormatHeaderElement(buffer, new BasicHeaderElement (cookieName, cookieValue), false); } else { // Netscape style cookies do not support quoted values buffer.Append(cookieName); buffer.Append("="); if (cookieValue != null) { buffer.Append(cookieValue); } } } IList<Header> headers = new AList<Header>(1); headers.AddItem(new BufferedHeader(buffer)); return headers; }
private static string FormatCooke(Apache.Http.Cookie.Cookie cookie) { StringBuilder buf = new StringBuilder(); buf.Append(cookie.GetName()); buf.Append("=\""); string v = cookie.GetValue(); if (v.Length > 100) { v = Sharpen.Runtime.Substring(v, 0, 100) + "..."; } buf.Append(v); buf.Append("\""); buf.Append(", version:"); buf.Append(Sharpen.Extensions.ToString(cookie.GetVersion())); buf.Append(", domain:"); buf.Append(cookie.GetDomain()); buf.Append(", path:"); buf.Append(cookie.GetPath()); buf.Append(", expiry:"); buf.Append(cookie.GetExpiryDate()); return(buf.ToString()); }