public string GetCookieHeader (Uri uri)
{
if (uri == null)
throw new ArgumentNullException ("uri");
CookieCollection coll = GetCookies (uri);
if (coll.Count == 0)
return "";
StringBuilder result = new StringBuilder ();
foreach (Cookie cookie in coll) {
// don't include the domain since it can be infered from the URI
// include empty path as '/'
result.Append (cookie.ToString (uri));
result.Append ("; ");
}
if (result.Length > 0)
result.Length -= 2; // remove trailing semicolon and space
return result.ToString ();
}