예제 #1
0
        internal static HttpVersion ValueOf(AsciiString text)
        {
            if (text is null)
            {
                ThrowHelper.ThrowArgumentException_NullText();
            }

            // ReSharper disable once PossibleNullReferenceException
            HttpVersion version = ValueOfInline(text.Array);

            if (version is object)
            {
                return(version);
            }

            // Fall back to slow path
            text = text.Trim();

            if (0u >= (uint)text.Count)
            {
                ThrowHelper.ThrowArgumentException_EmptyText();
            }

            // Try to match without convert to uppercase first as this is what 99% of all clients
            // will send anyway. Also there is a change to the RFC to make it clear that it is
            // expected to be case-sensitive
            //
            // See:
            // * http://trac.tools.ietf.org/wg/httpbis/trac/ticket/1
            // * http://trac.tools.ietf.org/wg/httpbis/trac/wiki
            //
            return(Version0(text) ?? new HttpVersion(text.ToString(), true));
        }