- remove redundant `null` check in `InputFormatter` - improve comments - rename `ObjectResult.SelectFormatterBasedOnTypeMatch()` -> `SelectFormatterNotUsingAcceptHeaders()`
This commit is contained in:
parent
fbf66168fe
commit
9b004611e5
|
|
@ -62,7 +62,7 @@ namespace Microsoft.AspNet.Mvc.Formatters
|
|||
|
||||
var contentType = context.HttpContext.Request.ContentType;
|
||||
MediaTypeHeaderValue requestContentType;
|
||||
if (!MediaTypeHeaderValue.TryParse(contentType, out requestContentType) || requestContentType == null)
|
||||
if (!MediaTypeHeaderValue.TryParse(contentType, out requestContentType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ namespace Microsoft.AspNet.Mvc.Formatters
|
|||
// Copy the media type as we don't want it to affect the next request
|
||||
selectedMediaType = selectedMediaType.Copy();
|
||||
|
||||
// Note text-based media types will use an encoding/charset - binary formats just ignore it. We want to
|
||||
// Note: Text-based media types will use an encoding/charset - binary formats just ignore it. We want to
|
||||
// make this class work with media types that use encodings, and those that don't.
|
||||
//
|
||||
// The default implementation of SelectCharacterEncoding will read from the list of SupportedEncodings
|
||||
|
|
|
|||
|
|
@ -103,12 +103,12 @@ namespace Microsoft.AspNet.Mvc
|
|||
if (ContentTypes == null || ContentTypes.Count == 0)
|
||||
{
|
||||
// Check if we have enough information to do content-negotiation, otherwise get the first formatter
|
||||
// which can write the type.
|
||||
// which can write the type. Let the formatter choose the Content-Type.
|
||||
if (!sortedAcceptHeaderMediaTypes.Any())
|
||||
{
|
||||
logger.LogVerbose("No information found on request to perform content negotiation.");
|
||||
|
||||
return SelectFormatterBasedOnTypeMatch(formatterContext, formatters);
|
||||
return SelectFormatterNotUsingAcceptHeaders(formatterContext, formatters);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -121,7 +121,8 @@ namespace Microsoft.AspNet.Mvc
|
|||
formatters,
|
||||
sortedAcceptHeaderMediaTypes);
|
||||
|
||||
// 2. No formatter was found based on Accept header. Fallback to type-based match.
|
||||
// 2. No formatter was found based on Accept header. Fallback to the first formatter which can write
|
||||
// the type. Let the formatter choose the Content-Type.
|
||||
if (selectedFormatter == null)
|
||||
{
|
||||
logger.LogVerbose("Could not find an output formatter based on content negotiation.");
|
||||
|
|
@ -130,7 +131,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
// if they want to write the response or not.
|
||||
formatterContext.FailedContentNegotiation = true;
|
||||
|
||||
return SelectFormatterBasedOnTypeMatch(formatterContext, formatters);
|
||||
return SelectFormatterNotUsingAcceptHeaders(formatterContext, formatters);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -167,7 +168,7 @@ namespace Microsoft.AspNet.Mvc
|
|||
return selectedFormatter;
|
||||
}
|
||||
|
||||
public virtual IOutputFormatter SelectFormatterBasedOnTypeMatch(
|
||||
public virtual IOutputFormatter SelectFormatterNotUsingAcceptHeaders(
|
||||
OutputFormatterContext formatterContext,
|
||||
IEnumerable<IOutputFormatter> formatters)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue