public bool ReadHeader(out string headerName, out string headerValue)
{
int index = 0;
while (index < _span.Length && ValidHeaderNameChar(_span[index]))
{
index++;
}
if (index > 0)
{
// For compatability, skip past any whitespace before the colon, even though
// the RFC suggests there shouldn't be any.
int headerNameLength = index;
while (index < _span.Length && IsWhiteSpaceLatin1(_span[index]))
{
index++;
}
CheckResponseMsgFormat(index < _span.Length);
CheckResponseMsgFormat(_span[index] == ':');
HeaderBufferSpan headerNameSpan = _span.Substring(0, headerNameLength);
if (!HttpKnownHeaderNames.TryGetHeaderName(_span.Buffer, _span.Length, out headerName))
{
headerName = headerNameSpan.ToString();
}
CheckResponseMsgFormat(headerName.Length > 0);
index++;
headerValue = _span.Substring(index).Trim().ToString();
return true;
}
headerName = null;
headerValue = null;
return false;
}