Esempio n. 1
0
        public static bool TryParseMethod(ByteSpan buffer, out HttpMethod method, out int parsedBytes)
        {
            if (buffer.StartsWith(s_Get.Bytes))
            {
                method      = HttpMethod.Get;
                parsedBytes = s_Get.Length;
                return(true);
            }

            if (buffer.StartsWith(s_Post.Bytes))
            {
                method      = HttpMethod.Post;
                parsedBytes = s_Post.Length;
                return(true);
            }

            if (buffer.StartsWith(s_Put.Bytes))
            {
                method      = HttpMethod.Put;
                parsedBytes = s_Put.Length;
                return(true);
            }

            if (buffer.StartsWith(s_Delete.Bytes))
            {
                method      = HttpMethod.Delete;
                parsedBytes = s_Delete.Length;
                return(true);
            }

            method      = HttpMethod.Unknown;
            parsedBytes = 0;
            return(false);
        }
Esempio n. 2
0
        public static bool TryParseMethod(ByteSpan buffer, out HttpMethod method, out int parsedBytes)
        {
            if(buffer.StartsWith(s_Get.Bytes))
            {
                method = HttpMethod.Get;
                parsedBytes = s_Get.Length;
                return true;
            }

            if (buffer.StartsWith(s_Post.Bytes))
            {
                method = HttpMethod.Post;
                parsedBytes = s_Post.Length;
                return true;
            }

            if (buffer.StartsWith(s_Put.Bytes))
            {
                method = HttpMethod.Put;
                parsedBytes = s_Put.Length;
                return true;
            }

            if (buffer.StartsWith(s_Delete.Bytes))
            {
                method = HttpMethod.Delete;
                parsedBytes = s_Delete.Length;
                return true;
            }

            method = HttpMethod.Unknown;
            parsedBytes = 0;
            return false;
        }