using System.Collections.Generic; using System.Linq; namespace Aki.Common.Http { public static class WebConstants { /// /// HTML GET method. /// public const string Get = "GET"; /// /// HTML HEAD method. /// public const string Head = "HEAD"; /// /// HTML POST method. /// public const string Post = "POST"; /// /// HTML PUT method. /// public const string Put = "PUT"; /// /// HTML DELETE method. /// public const string Delete = "DELETE"; /// /// HTML CONNECT method. /// public const string Connect = "CONNECT"; /// /// HTML OPTIONS method. /// public const string Options = "OPTIONS"; /// /// HTML TRACE method. /// public const string Trace = "TRACE"; /// /// HTML MIME types. /// public static Dictionary Mime { get; private set; } static WebConstants() { Mime = new Dictionary() { { ".bin", "application/octet-stream" }, { ".txt", "text/plain" }, { ".htm", "text/html" }, { ".html", "text/html" }, { ".css", "text/css" }, { ".js", "text/javascript" }, { ".jpeg", "image/jpeg" }, { ".jpg", "image/jpeg" }, { ".png", "image/png" }, { ".ico", "image/vnd.microsoft.icon" }, { ".json", "application/json" } }; } /// /// Is HTML method valid? /// public static bool IsValidMethod(string method) { return method == Get || method == Head || method == Post || method == Put || method == Delete || method == Connect || method == Options || method == Trace; } /// /// Is MIME type valid? /// public static bool IsValidMime(string mime) { return Mime.Any(x => x.Value == mime); } } }