private static string GetReasonPhrase(HttpStatusCode statusCode, char[] buffer, int bufferLength)
{
CharArrayHelpers.DebugAssertArrayInputs(buffer, 0, bufferLength);
Debug.Assert(bufferLength > 0);
// If it's a known reason phrase, use the known reason phrase instead of allocating a new string.
string knownReasonPhrase = HttpStatusDescription.Get(statusCode);
return (knownReasonPhrase != null && CharArrayHelpers.EqualsOrdinal(knownReasonPhrase, buffer, 0, bufferLength)) ?
knownReasonPhrase :
new string(buffer, 0, bufferLength);
}