11 #region from System.Uri
13 internal static bool MaybeUri (string s)
15 int p = s.IndexOf (':');
22 return IsPredefinedScheme (s.Substring (0, p));
25 private static bool IsPredefinedScheme (string scheme)
48 #region from System.Net.Cookiie
50 internal static string ToClientString (System.Net.Cookie cookie)
52 if (cookie.Name.Length == 0)
55 StringBuilder result = new StringBuilder (64);
57 if (cookie.Version > 0)
58 result.Append ("Version=").Append (cookie.Version).Append (";");
60 result.Append (cookie.Name).Append ("=").Append (cookie.Value);
62 if (cookie.Path != null && cookie.Path.Length != 0)
63 result.Append (";Path=").Append (QuotedString (cookie, cookie.Path));
65 if (cookie.Domain != null && cookie.Domain.Length != 0)
66 result.Append (";Domain=").Append (QuotedString (cookie, cookie.Domain));
68 if (cookie.Port != null && cookie.Port.Length != 0)
69 result.Append (";Port=").Append (cookie.Port);
71 return result.ToString ();
74 // See par 3.6 of RFC 2616
75 static string QuotedString (System.Net.Cookie cookie, string value)
77 if (cookie.Version == 0 || IsToken (value))
80 return "\"" + value.Replace("\"", "\\\"") + "\"";
83 static bool IsToken (string value)
85 int len = value.Length;
86 for (int i = 0; i < len; i++) {
88 if (c < 0x20 || c >= 0x7f || tspecials.IndexOf (c) != -1)
94 static string tspecials = "()<>@,;:\\\"/[]?={} \t"; // from RFC 2965, 2068