private void ParseRoutingTokenOrCookie(byte[] data, ref byte[] routingToken, ref String cookie, ref int currentIndex)
{
bool isPresent = false;
int offset;
for (offset = 0; currentIndex + offset < data.Length - 1; offset++)
{
if (data[currentIndex + offset] == 0x0D && data[currentIndex + offset + 1] == 0x0A)
{
isPresent = true;
break;
}
}
if (isPresent)
{
routingToken = new byte[offset + 2];
Array.Copy(data, currentIndex, routingToken, 0, offset + 2);
cookie = ASCIIEncoding.ASCII.GetString(routingToken);
if (cookie.StartsWith("Cookie"))
{// cookie is present
routingToken = null;
}
else
{
cookie = null;
}
currentIndex += (offset + 2);
}
else
{
routingToken = null;
cookie = null;
}
}