// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. using System.Net.Http; namespace System.Web.Http { /// /// Various helper methods for the static members of . /// internal static class HttpMethodHelper { /// /// Gets the static instance for any given HTTP method name. /// /// The HTTP request method. /// An existing static or a new instance if the method was not found. internal static HttpMethod GetHttpMethod(string method) { if (String.IsNullOrEmpty(method)) { return null; } if (String.Equals("GET", method, StringComparison.OrdinalIgnoreCase)) { return HttpMethod.Get; } if (String.Equals("POST", method, StringComparison.OrdinalIgnoreCase)) { return HttpMethod.Post; } if (String.Equals("PUT", method, StringComparison.OrdinalIgnoreCase)) { return HttpMethod.Put; } if (String.Equals("DELETE", method, StringComparison.OrdinalIgnoreCase)) { return HttpMethod.Delete; } if (String.Equals("HEAD", method, StringComparison.OrdinalIgnoreCase)) { return HttpMethod.Head; } if (String.Equals("OPTIONS", method, StringComparison.OrdinalIgnoreCase)) { return HttpMethod.Options; } if (String.Equals("TRACE", method, StringComparison.OrdinalIgnoreCase)) { return HttpMethod.Trace; } return new HttpMethod(method); } } }