Skip to content

[API Proposal]: Add multipart/related to MediaTypeNames.Multipart #95446

Closed
@CollinAlpert

Description

@CollinAlpert

Background and motivation

The System.Net.Mime.MediaTypeNames.Multipart type already contains a constant for multipart/form-data which can be used by developers instead of introducing own constants at the risk of typos or duplication.

The same should exist for multipart/related.

API Proposal

namespace System.Net.Mime;

public static class MediaTypeNames
{
    public static class Multipart
    {
         // see https://www.ietf.org/rfc/rfc2387.txt
+        public const string Related = "multipart/related";
         // see https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html
+        public const string Mixed = "multipart/mixed"
    }
    public static class Application
    {
         // https://datatracker.ietf.org/doc/html/rfc6713
+        public const string Gzip = "application/gzip";
         // see https://github.com/ndjson/ndjson-spec
+        public const string NDJson = "application/x-ndjson";
    }
    public static class Text
    {
        // see https://github.com/dotnet/runtime/issues/102194
+       public const string EventStream = "text/event-stream";
    }
}

API Usage

using Microsoft.AspNetCore.Http;
using System.Net.Mime;

void M(HttpRequest request)
{
    Console.WriteLine(request.ContentType == MediaTypeNames.Multipart.Related)
}

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-System.Netin-prThere is an active PR which will close this issue when it is merged

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions