14 instantiations of MediaTypeHeaderValue
Microsoft.AspNetCore.Diagnostics (1)
DeveloperExceptionPage\DeveloperExceptionPageMiddlewareImpl.cs (1)
41private static readonly MediaTypeHeaderValue _textHtmlMediaType = new MediaTypeHeaderValue("text/html");
Microsoft.AspNetCore.Http (2)
Features\FormFeature.cs (2)
35 _formContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded"); 132_formContentType ??= new MediaTypeHeaderValue("application/x-www-form-urlencoded");
Microsoft.AspNetCore.Http.Connections (1)
Internal\HttpConnectionDispatcher.cs (1)
133if (headers.Accept?.Contains(new Net.Http.Headers.MediaTypeHeaderValue("text/event-stream")) == true)
Microsoft.AspNetCore.Http.Extensions (2)
DefaultProblemDetailsWriter.cs (2)
14private static readonly MediaTypeHeaderValue _jsonMediaType = new("application/json"); 15private static readonly MediaTypeHeaderValue _problemDetailsJsonMediaType = new("application/problem+json");
Microsoft.AspNetCore.Mvc.Core (1)
Infrastructure\SystemTextJsonResultExecutor.cs (1)
18private static readonly string DefaultContentType = new MediaTypeHeaderValue("application/json")
Microsoft.AspNetCore.Watch.BrowserRefresh (3)
src\sdk\src\Dotnet.Watch\Web.Middleware\BrowserRefreshMiddleware.cs (2)
20private static readonly MediaTypeHeaderValue s_textHtmlMediaType = new("text/html"); 21private static readonly MediaTypeHeaderValue s_applicationJsonMediaType = new("application/json");
src\sdk\src\Dotnet.Watch\Web.Middleware\ResponseStreamWrapper.cs (1)
26private static readonly MediaTypeHeaderValue s_textHtmlMediaType = new("text/html");
Microsoft.Net.Http.Headers (4)
MediaTypeHeaderValue.cs (4)
405var other = new MediaTypeHeaderValue(); 428var other = new MediaTypeHeaderValue(); 586mediaTypeHeader = new MediaTypeHeaderValue(); 598mediaTypeHeader = new MediaTypeHeaderValue();
183 references to MediaTypeHeaderValue
Microsoft.AspNetCore.Components.Endpoints (2)
RazorComponentEndpointInvoker.cs (2)
210if (context.Request.ContentType is not null && MediaTypeHeaderValue.TryParse(context.Request.ContentType, out var type))
Microsoft.AspNetCore.Diagnostics (1)
DeveloperExceptionPage\DeveloperExceptionPageMiddlewareImpl.cs (1)
41private static readonly MediaTypeHeaderValue _textHtmlMediaType = new MediaTypeHeaderValue("text/html");
Microsoft.AspNetCore.HeaderParsing (10)
CommonHeaders.cs (2)
25public static HeaderSetup<IReadOnlyList<MediaTypeHeaderValue>> Accept => new(HeaderNames.Accept, MediaTypeHeaderValueListParser.Instance); 50public static HeaderSetup<MediaTypeHeaderValue> ContentType => new(HeaderNames.ContentType, MediaTypeHeaderValueParser.Instance, cacheable: true);
Parsers\MediaTypeHeaderValueListParser.cs (4)
11internal sealed class MediaTypeHeaderValueListParser : HeaderParser<IReadOnlyList<MediaTypeHeaderValue>> 15public override bool TryParse(StringValues values, [NotNullWhen(true)] out IReadOnlyList<MediaTypeHeaderValue>? result, [NotNullWhen(false)] out string? error) 17if (!MediaTypeHeaderValue.TryParseList(values, out var parsedValues)) 25result = (IReadOnlyList<MediaTypeHeaderValue>)parsedValues;
Parsers\MediaTypeHeaderValueParser.cs (4)
10internal sealed class MediaTypeHeaderValueParser : HeaderParser<MediaTypeHeaderValue> 14public override bool TryParse(StringValues values, [NotNullWhen(true)] out MediaTypeHeaderValue? result, [NotNullWhen(false)] out string? error) 16if (values.Count != 1 || !MediaTypeHeaderValue.TryParse(values[0], out var parsedValue))
Microsoft.AspNetCore.Http (9)
Features\FormFeature.cs (9)
24 private MediaTypeHeaderValue? _formContentType; // null iff _form is null 71private MediaTypeHeaderValue? ContentType 75MediaTypeHeaderValue? mt = null; 79_ = MediaTypeHeaderValue.TryParse(_request.ContentType, out mt); 107var contentType = ContentType; 210var contentType = ContentType; 345private static bool HasApplicationFormContentType([NotNullWhen(true)] MediaTypeHeaderValue? contentType) 351private static bool HasMultipartFormContentType([NotNullWhen(true)] MediaTypeHeaderValue? contentType) 378private static string GetBoundary(MediaTypeHeaderValue contentType, int lengthLimit)
Microsoft.AspNetCore.Http.Abstractions (1)
Metadata\ProducesResponseTypeMetadata.cs (1)
39MediaTypeHeaderValue.Parse(contentTypes[i]);
Microsoft.AspNetCore.Http.Extensions (22)
DefaultProblemDetailsWriter.cs (4)
14private static readonly MediaTypeHeaderValue _jsonMediaType = new("application/json"); 15private static readonly MediaTypeHeaderValue _problemDetailsJsonMediaType = new("application/problem+json"); 29var acceptHeader = httpContext.Request.Headers.Accept.GetList<MediaTypeHeaderValue>(); 40var acceptHeaderValue = acceptHeader[i];
HeaderDictionaryTypeExtensions.cs (8)
141private static MediaTypeHeaderValue? ParseCacheMediaTypeHeaderValue(string value) => MediaTypeHeaderValue.TryParse(value, out var result) ? result : null; 153private static IList<MediaTypeHeaderValue> ParseMediaTypeHeaderValue(IList<string> value) => 154MediaTypeHeaderValue.TryParseList(value, out var result) ? result : Array.Empty<MediaTypeHeaderValue>(); 192else if (typeof(T) == typeof(MediaTypeHeaderValue)) 237if (typeof(T) == typeof(MediaTypeHeaderValue))
HttpRequestJsonExtensions.cs (2)
373if (!MediaTypeHeaderValue.TryParse(request.ContentType, out var mt))
HttpRequestMultipartExtensions.cs (2)
22if (!MediaTypeHeaderValue.TryParse(request.ContentType, out var mediaType))
RequestHeaders.cs (4)
34public IList<MediaTypeHeaderValue> Accept 38return Headers.Accept.GetList<MediaTypeHeaderValue>(); 154public MediaTypeHeaderValue? ContentType 158return Headers.Get<MediaTypeHeaderValue>(HeaderNames.ContentType);
ResponseHeaders.cs (2)
94public MediaTypeHeaderValue? ContentType 98return Headers.Get<MediaTypeHeaderValue>(HeaderNames.ContentType);
Microsoft.AspNetCore.Http.Results (6)
Results.cs (1)
170public static IResult Content(string? content, MediaTypeHeaderValue contentType)
src\aspnetcore\src\Shared\ResponseContentTypeHelper.cs (2)
70if (MediaTypeHeaderValue.TryParse(mediaType, out var parsed))
TypedResults.cs (3)
167MediaTypeHeaderValue? mediaTypeHeaderValue = null; 170mediaTypeHeaderValue = MediaTypeHeaderValue.Parse(contentType); 183public static ContentHttpResult Content(string? content, MediaTypeHeaderValue contentType)
Microsoft.AspNetCore.HttpLogging (11)
MediaTypeHelpers.cs (3)
30if (!MediaTypeHeaderValue.TryParse(contentType, out var mediaType)) 37var type = state.MediaTypeHeaderValue;
MediaTypeOptions.cs (8)
34internal void AddText(MediaTypeHeaderValue mediaType) 54AddText(MediaTypeHeaderValue.Parse(contentType)); 67var mediaType = MediaTypeHeaderValue.Parse(contentType); 73/// Adds a <see cref="MediaTypeHeaderValue"/> to be used for logging as binary. 76public void AddBinary(MediaTypeHeaderValue mediaType) 100public MediaTypeState(MediaTypeHeaderValue mediaTypeHeaderValue) 107public MediaTypeHeaderValue MediaTypeHeaderValue { get; }
Microsoft.AspNetCore.Mvc.Core (42)
ConsumesAttribute.cs (4)
45MediaTypeHeaderValue.Parse(contentType); 49MediaTypeHeaderValue.Parse(otherContentTypes[i]); 68MediaTypeHeaderValue.Parse(contentType); 72MediaTypeHeaderValue.Parse(otherContentTypes[i]);
ControllerBase.cs (5)
244=> Content(content, (MediaTypeHeaderValue?)null); 255=> Content(content, MediaTypeHeaderValue.Parse(contentType)); 272var mediaTypeHeaderValue = MediaTypeHeaderValue.Parse(contentType); 285public virtual ContentResult Content(string content, MediaTypeHeaderValue? contentType)
FileContentResult.cs (2)
27: this(fileContents, MediaTypeHeaderValue.Parse(contentType)) 38public FileContentResult(byte[] fileContents, MediaTypeHeaderValue contentType)
FileStreamResult.cs (2)
27: this(fileStream, MediaTypeHeaderValue.Parse(contentType)) 38public FileStreamResult(Stream fileStream, MediaTypeHeaderValue contentType)
Formatters\FormatterMappings.cs (3)
29SetMediaTypeMappingForFormat(format, MediaTypeHeaderValue.Parse(contentType)); 38public void SetMediaTypeMappingForFormat(string format, MediaTypeHeaderValue contentType) 83private static void ValidateContentType(MediaTypeHeaderValue contentType)
Formatters\MediaTypeCollection.cs (3)
18public void Add(MediaTypeHeaderValue item) 30public void Insert(int index, MediaTypeHeaderValue item) 49public bool Remove(MediaTypeHeaderValue item)
Formatters\MediaTypeHeaderValues.cs (12)
10public static readonly MediaTypeHeaderValue ApplicationJson 11= MediaTypeHeaderValue.Parse("application/json").CopyAsReadOnly(); 13public static readonly MediaTypeHeaderValue TextJson 14= MediaTypeHeaderValue.Parse("text/json").CopyAsReadOnly(); 16public static readonly MediaTypeHeaderValue ApplicationAnyJsonSyntax 17= MediaTypeHeaderValue.Parse("application/*+json").CopyAsReadOnly(); 19public static readonly MediaTypeHeaderValue ApplicationXml 20= MediaTypeHeaderValue.Parse("application/xml").CopyAsReadOnly(); 22public static readonly MediaTypeHeaderValue TextXml 23= MediaTypeHeaderValue.Parse("text/xml").CopyAsReadOnly(); 25public static readonly MediaTypeHeaderValue ApplicationAnyXmlSyntax 26= MediaTypeHeaderValue.Parse("application/*+xml").CopyAsReadOnly();
JsonResult.cs (1)
44/// Gets or sets the <see cref="Net.Http.Headers.MediaTypeHeaderValue"/> representing the Content-Type header of the response.
PhysicalFileResult.cs (2)
26: this(fileName, MediaTypeHeaderValue.Parse(contentType)) 37public PhysicalFileResult(string fileName, MediaTypeHeaderValue contentType)
ProducesAttribute.cs (2)
42MediaTypeHeaderValue.Parse(contentType); 46MediaTypeHeaderValue.Parse(additionalContentTypes[i]);
ProducesResponseTypeAttribute.cs (2)
56MediaTypeHeaderValue.Parse(contentType); 59MediaTypeHeaderValue.Parse(additionalContentTypes[i]);
src\aspnetcore\src\Shared\ResponseContentTypeHelper.cs (2)
70if (MediaTypeHeaderValue.TryParse(mediaType, out var parsed))
VirtualFileResult.cs (2)
27: this(fileName, MediaTypeHeaderValue.Parse(contentType)) 38public VirtualFileResult(string fileName, MediaTypeHeaderValue contentType)
Microsoft.AspNetCore.Mvc.RazorPages (10)
PageBase.cs (5)
214=> Content(content, (MediaTypeHeaderValue?)null); 224=> Content(content, MediaTypeHeaderValue.Parse(contentType)); 240var mediaTypeHeaderValue = MediaTypeHeaderValue.Parse(contentType); 252public virtual ContentResult Content(string content, MediaTypeHeaderValue? contentType)
PageModel.cs (5)
546=> Content(content, (MediaTypeHeaderValue?)null); 556=> Content(content, MediaTypeHeaderValue.Parse(contentType)); 572var mediaTypeHeaderValue = MediaTypeHeaderValue.Parse(contentType); 584public virtual ContentResult Content(string content, MediaTypeHeaderValue? contentType)
Microsoft.AspNetCore.Watch.BrowserRefresh (7)
src\sdk\src\Dotnet.Watch\Web.Middleware\BrowserRefreshMiddleware.cs (4)
20private static readonly MediaTypeHeaderValue s_textHtmlMediaType = new("text/html"); 21private static readonly MediaTypeHeaderValue s_applicationJsonMediaType = new("application/json"); 152if (typedHeaders.Accept is not IList<MediaTypeHeaderValue> acceptHeaders) 189if (typedHeaders.Accept is not IList<MediaTypeHeaderValue> acceptHeaders)
src\sdk\src\Dotnet.Watch\Web.Middleware\ResponseStreamWrapper.cs (3)
26private static readonly MediaTypeHeaderValue s_textHtmlMediaType = new("text/html"); 108MediaTypeHeaderValue.TryParse(response.ContentType, out var mediaType) &&
Microsoft.AspNetCore.WebUtilities (2)
MultipartSectionStreamExtensions.cs (2)
37_ = MediaTypeHeaderValue.TryParse(section.ContentType, out var sectionMediaType);
Microsoft.Net.Http.Headers (60)
MediaTypeHeaderValue.cs (54)
30private static readonly HttpHeaderParser<MediaTypeHeaderValue> SingleValueParser 31= new GenericHeaderParser<MediaTypeHeaderValue>(false, GetMediaTypeLength); 32private static readonly HttpHeaderParser<MediaTypeHeaderValue> MultipleValueParser 33= new GenericHeaderParser<MediaTypeHeaderValue>(true, GetMediaTypeLength); 46/// Initializes a <see cref="MediaTypeHeaderValue"/> instance. 57/// Initializes a <see cref="MediaTypeHeaderValue"/> instance. 237/// Gets the type of the <see cref="MediaTypeHeaderValue"/>. 252/// Gets the subtype of the <see cref="MediaTypeHeaderValue"/>. 268/// Gets subtype of the <see cref="MediaTypeHeaderValue"/>, excluding any structured syntax suffix. Returns <see cref="StringSegment.Empty"/> 293/// Gets the structured syntax suffix of the <see cref="MediaTypeHeaderValue"/> if it has one. 318/// Get a <see cref="IList{T}"/> of facets of the <see cref="MediaTypeHeaderValue"/>. Facets are a 335/// Gets whether this <see cref="MediaTypeHeaderValue"/> matches all types. 340/// Gets whether this <see cref="MediaTypeHeaderValue"/> matches all subtypes. 351/// Gets whether this <see cref="MediaTypeHeaderValue"/> matches all subtypes, ignoring any structured syntax suffix. 363/// Gets whether the <see cref="MediaTypeHeaderValue"/> is readonly. 371/// Gets a value indicating whether this <see cref="MediaTypeHeaderValue"/> is a subset of 375/// <param name="otherMediaType">The <see cref="MediaTypeHeaderValue"/> to compare.</param> 377/// A value indicating whether this <see cref="MediaTypeHeaderValue"/> is a subset of 385public bool IsSubsetOf(MediaTypeHeaderValue otherMediaType) 403public MediaTypeHeaderValue Copy() 405var other = new MediaTypeHeaderValue(); 421public MediaTypeHeaderValue CopyAsReadOnly() 428var other = new MediaTypeHeaderValue(); 441/// this <see cref="MediaTypeHeaderValue"/> in terms of type/subType. A "subset" is defined as the same or a more specific media type 447/// this <see cref="MediaTypeHeaderValue"/>. 476var other = obj as MediaTypeHeaderValue; 495/// Takes a media type and parses it into the <see cref="MediaTypeHeaderValue" /> and its associated parameters. 498/// <returns>The parsed <see cref="MediaTypeHeaderValue"/>.</returns> 499public static MediaTypeHeaderValue Parse(StringSegment input) 506/// Takes a media type, which can include parameters, and parses it into the <see cref="MediaTypeHeaderValue" /> and its associated parameters. 509/// <param name="parsedValue">The parsed <see cref="MediaTypeHeaderValue"/></param> 511public static bool TryParse(StringSegment input, [NotNullWhen(true)] out MediaTypeHeaderValue? parsedValue) 518/// Takes an <see cref="IList{T}"/> of <see cref="string"/> and parses it into the <see cref="MediaTypeHeaderValue"></see> and its associated parameters. 521/// <returns>The parsed <see cref="MediaTypeHeaderValue"/>.</returns> 522public static IList<MediaTypeHeaderValue> ParseList(IList<string>? inputs) 528/// Takes an <see cref="IList{T}"/> of <see cref="string"/> and parses it into the <see cref="MediaTypeHeaderValue"></see> and its associated parameters. 532/// <returns>The parsed <see cref="MediaTypeHeaderValue"/>.</returns> 533public static IList<MediaTypeHeaderValue> ParseStrictList(IList<string>? inputs) 539/// Takes an <see cref="IList{T}"/> of <see cref="string"/> and parses it into the <see cref="MediaTypeHeaderValue"></see> and its associated parameters. 542/// <param name="parsedValues">The parsed <see cref="MediaTypeHeaderValue"/>.</param> 544public static bool TryParseList(IList<string>? inputs, [NotNullWhen(true)] out IList<MediaTypeHeaderValue>? parsedValues) 550/// Takes an <see cref="IList{T}"/> of <see cref="string"/> and parses it into the <see cref="MediaTypeHeaderValue"></see> and its associated parameters. 553/// <param name="parsedValues">The parsed <see cref="MediaTypeHeaderValue"/>.</param> 555public static bool TryParseStrictList(IList<string>? inputs, [NotNullWhen(true)] out IList<MediaTypeHeaderValue>? parsedValues) 560private static int GetMediaTypeLength(StringSegment input, int startIndex, out MediaTypeHeaderValue? parsedValue) 572var mediaTypeLength = MediaTypeHeaderValue.GetMediaTypeExpressionLength(input, startIndex, out var mediaType); 581MediaTypeHeaderValue? mediaTypeHeader; 669private bool MatchesType(MediaTypeHeaderValue set) 683private bool MatchesSubtype(MediaTypeHeaderValue set) 750private bool MatchesSubtypeWithoutSuffix(MediaTypeHeaderValue set) 771private bool MatchesEitherSubtypeOrSuffix(MediaTypeHeaderValue set) 783private bool MatchesParameters(MediaTypeHeaderValue set) 821private bool MatchesSubtypeSuffix(MediaTypeHeaderValue set)
MediaTypeHeaderValueComparer.cs (6)
10public class MediaTypeHeaderValueComparer : IComparer<MediaTypeHeaderValue> 27/// subtype wildcards. This allows callers to sort a sequence of <see cref="MediaTypeHeaderValue"/> following 34public int Compare(MediaTypeHeaderValue? mediaType1, MediaTypeHeaderValue? mediaType2) 118MediaTypeHeaderValue mediaType1, 119MediaTypeHeaderValue mediaType2)