private static void UpdateStringCollection(StringCollection result, NameValueCollection cc, bool winInetCompat)
{
StringBuilder sb;
// Transfer headers
for (int i=0; i < cc.Count; ++i)
{
sb = new StringBuilder(40);
string key = cc.GetKey(i) as string;
sb.Append(key).Append(':');
string[] val = cc.GetValues(i);
if (val.Length != 0)
{
if (winInetCompat)
{sb.Append(val[0]);}
else
{sb.Append(' ').Append(val[0]);}
}
for (int j = 1; j < val.Length; ++j)
{
sb.Append(key).Append(", ").Append(val[j]);
}
result.Add(sb.ToString());
}
// Transfer last \r\n
result.Add(string.Empty);
}