dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.99k stars 4.66k forks source link

[API Proposal]: add more entries to MediaTypeNames #85807

Closed wfurt closed 1 year ago

wfurt commented 1 year ago

Background and motivation

This is primarily community driven, long discussion in #1489. This is primarily convenience to somewhat match common patterns for web applications.

Additional sources are: IANA Media Types

API Proposal

namespace System.Net.Mime;

    public static class MediaTypeNames
    {
        public static class Text
        {
            public const string Plain = "text/plain";
            public const string Html = "text/html";
            public const string Xml = "text/xml";
            public const string RichText = "text/richtext";
+           public const string Css = "text/css";                 // RFC2318
+           public const string Csv = "text/csv";                 // RFC4180
+           public const string JavaScript = "text/javascript";   // RFC9239
+           public const string Markdown = "text/markdown";       // RFC7763
+           public const string Rtf = "text/rtf";
        }

        public static class Application
        {
            public const string Soap = "application/soap+xml";
            public const string Octet = "application/octet-stream";
            public const string Rtf = "application/rtf";
            public const string Pdf = "application/pdf";
            public const string Zip = "application/zip";
            public const string Json = "application/json";
            public const string Xml = "application/xml";
+           public const string FormUrlEncoded = "application/x-www-form-urlencoded"; 
+           public const string JsonPatch = "application/json-patch+json"; // RFC6902
+           public const string JsonSequence = "application/json-seq";     // RFC7464
+           public const string Manifest = "application/manifest+json";    // W3C
+           public const string ProblemJson = "application/problem+json";  // RFC7807
+           public const string ProblemXml = "application/problem+xml";    // RFC7807
+           public const string Wasm = "application/wasm";                 // W3C
+           public const string XmlDtd = "application/xml-dtd";            // RFC7303
+           public const string XmlPatch = "application/xml-patch+xml";    // RFC735
        }

        public static class Image
        {
            public const string Gif = "image/gif";
            public const string Tiff = "image/tiff";
            public const string Jpeg = "image/jpeg";
+           public const string Avif = "image/avif";
+           public const string Bmp = "image/bmp";     // RFC7903
+           public const string Icon = "image/x-icon"; 
+           public const string Png = "image/png";     // W3C
+           public const string Svg = "image/svg+xml"; // W3C
+           public const string Webp = "image/webp";
        }

+        public static class Multipart
+        {
+           public const string ByteRanges = "multipart/byteranges";  // RFC9110
+           public const string FormData = "multipart/form-data";     // RFC7578
+        }

+        public static class Font
+        {
+           public const string Collection = "font/collection"; // RFC8081
+           public const string Otf = "font/otf";               // RFC8081
+           public const string Sfnt = "font/sfnt";             // RFC8081
+           public const string Ttf = "font/ttf";               // RFC8081
+           public const string Woff = "font/woff";             // RFC8081
+           public const string Woff2 = "font/woff2";           // RFC8081
+        } 
    }

API Usage

there is not much, this is just convenience constant.

Alternative Designs

No response

Risks

small. Added constants will increase assembly size a tiny little bit.

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

Issue Details
### Background and motivation This is primarily community driven, long discussion in #1489. This is primarily convenience to somewhat match common patterns for web applications. Additional sources are: [IANA Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml) ### API Proposal ```c# namespace System.Net.Mime; public static class MediaTypeNames { public static class Text { public const string Plain = "text/plain"; public const string Html = "text/html"; public const string Xml = "text/xml"; public const string RichText = "text/richtext"; + public const string Css = "text/css"; // RFC2318 + public const string Csv = "text/csv"; // RFC4180 + public const string JavaScript = "text/javascript"; // RFC9239 + public const string Markdown = "text/markdown"; // RFC7763 + public const string Rtf = "text/rtf"; } public static class Application { public const string Soap = "application/soap+xml"; public const string Octet = "application/octet-stream"; public const string Rtf = "application/rtf"; public const string Pdf = "application/pdf"; public const string Zip = "application/zip"; public const string Json = "application/json"; public const string Xml = "application/xml"; + public const string FormUrlEncoded = "application/x-www-form-urlencoded"; + public const string JsonPatch = "application/json-patch+json"; // RFC6902 + public const string JsonSequence = "application/json-seq"; // RFC7464 + public const string Manifest = "application/manifest+json"; // W3C + public const string ProblemJson = "application/problem+json"; // RFC7807 + public const string ProblemXml = "application/problem+xml"; // RFC7807 + public const string Wasm = "application/wasm"; // W3C + public const string XmlDtd = "application/xml-dtd"; // RFC7303 + public const string XmlPatch = "application/xml-patch+xml"; // RFC735 } public static class Image { public const string Gif = "image/gif"; public const string Tiff = "image/tiff"; public const string Jpeg = "image/jpeg"; + public const string Avif = "image/avif"; + public const string Bmp = "image/bmp"; // RFC7903 + public const string Icon = "image/x-icon"; + public const string Png = "image/png"; // W3C + public const string Svg = "image/svg+xml"; // W3C + public const string Webp = "image/webp"; } + public static class Multipart + { + public const string ByteRanges = "multipart/byteranges"; // RFC9110 + public const string FormData = "multipart/form-data"; // RFC7578 + } + public static class Font + { + public const string Collection = "font/collection"; // RFC8081 + public const string Otf = "font/otf"; // RFC8081 + public const string Sfnt = "font/sfnt"; // RFC8081 + public const string Ttf = "font/ttf"; // RFC8081 + public const string Woff = "font/woff"; // RFC8081 + public const string Woff2 = "font/woff2"; // RFC8081 + } } ``` ### API Usage there is not much, this is just convenience constant. ### Alternative Designs _No response_ ### Risks small. Added constants will increase assembly size a tiny little bit.
Author: wfurt
Assignees: -
Labels: `api-suggestion`, `area-System.Net`
Milestone: 8.0.0
bartonjs commented 1 year ago

Video

Looks good as proposed

namespace System.Net.Mime;

    public static class MediaTypeNames
    {
        public static class Text
        {
            public const string Plain = "text/plain";
            public const string Html = "text/html";
            public const string Xml = "text/xml";
            public const string RichText = "text/richtext";
+           public const string Css = "text/css";                 // RFC2318
+           public const string Csv = "text/csv";                 // RFC4180
+           public const string JavaScript = "text/javascript";   // RFC9239
+           public const string Markdown = "text/markdown";       // RFC7763
+           public const string Rtf = "text/rtf";
        }

        public static class Application
        {
            public const string Soap = "application/soap+xml";
            public const string Octet = "application/octet-stream";
            public const string Rtf = "application/rtf";
            public const string Pdf = "application/pdf";
            public const string Zip = "application/zip";
            public const string Json = "application/json";
            public const string Xml = "application/xml";
+           public const string FormUrlEncoded = "application/x-www-form-urlencoded"; 
+           public const string JsonPatch = "application/json-patch+json"; // RFC6902
+           public const string JsonSequence = "application/json-seq";     // RFC7464
+           public const string Manifest = "application/manifest+json";    // W3C
+           public const string ProblemJson = "application/problem+json";  // RFC7807
+           public const string ProblemXml = "application/problem+xml";    // RFC7807
+           public const string Wasm = "application/wasm";                 // W3C
+           public const string XmlDtd = "application/xml-dtd";            // RFC7303
+           public const string XmlPatch = "application/xml-patch+xml";    // RFC735
        }

        public static class Image
        {
            public const string Gif = "image/gif";
            public const string Tiff = "image/tiff";
            public const string Jpeg = "image/jpeg";
+           public const string Avif = "image/avif";
+           public const string Bmp = "image/bmp";     // RFC7903
+           public const string Icon = "image/x-icon"; 
+           public const string Png = "image/png";     // W3C
+           public const string Svg = "image/svg+xml"; // W3C
+           public const string Webp = "image/webp";
        }

+        public static class Multipart
+        {
+           public const string ByteRanges = "multipart/byteranges";  // RFC9110
+           public const string FormData = "multipart/form-data";     // RFC7578
+        }

+        public static class Font
+        {
+           public const string Collection = "font/collection"; // RFC8081
+           public const string Otf = "font/otf";               // RFC8081
+           public const string Sfnt = "font/sfnt";             // RFC8081
+           public const string Ttf = "font/ttf";               // RFC8081
+           public const string Woff = "font/woff";             // RFC8081
+           public const string Woff2 = "font/woff2";           // RFC8081
+        } 
    }