コード例 #1
0
    private void CanonicalizedValueTest(string method, string expectedMethod)
    {
        string inputMethod        = CreateStringAtRuntime(method);
        var    canonicalizedValue = HttpMethods.GetCanonicalizedValue(inputMethod);

        Assert.Same(expectedMethod, canonicalizedValue);
    }
コード例 #2
0
        private static string GetCanonicalizedValue(string method)
        {
#if NET5_0
            return(HttpMethods.GetCanonicalizedValue(method));
#elif NETCOREAPP3_1
            return(method switch
            {
                string _ when HttpMethods.IsGet(method) => HttpMethods.Get,
                string _ when HttpMethods.IsPost(method) => HttpMethods.Post,
                string _ when HttpMethods.IsPut(method) => HttpMethods.Put,
                string _ when HttpMethods.IsDelete(method) => HttpMethods.Delete,
                string _ when HttpMethods.IsOptions(method) => HttpMethods.Options,
                string _ when HttpMethods.IsHead(method) => HttpMethods.Head,
                string _ when HttpMethods.IsPatch(method) => HttpMethods.Patch,
                string _ when HttpMethods.IsTrace(method) => HttpMethods.Trace,
                string _ when HttpMethods.IsConnect(method) => HttpMethods.Connect,
                string _ => method
            });