Change FormValueProviderFactory to use GetContentType for media type matching
Fixes #68
This commit is contained in:
parent
1ca2203421
commit
f1c4a8e497
|
|
@ -2,7 +2,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc.ModelBinding.Internal;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||
{
|
||||
public class ContentTypeHeaderValue
|
||||
internal class ContentTypeHeaderValue
|
||||
{
|
||||
public ContentTypeHeaderValue([NotNull] string contentType,
|
||||
string charSet)
|
||||
|
|
@ -18,6 +13,5 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
|
|||
public string ContentType { get; private set; }
|
||||
|
||||
public string CharSet { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
using System;
|
||||
using Microsoft.AspNet.Abstractions;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
|
||||
namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||
{
|
||||
public static class HttpRequestExtensions
|
||||
internal static class HttpRequestExtensions
|
||||
{
|
||||
private const string ContentTypeHeader = "Content-Type";
|
||||
private const string CharSetToken = "charset=";
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
|
|||
|
||||
private bool IsSupportedContentType(HttpRequest request)
|
||||
{
|
||||
var contentType = request.Headers["Content-Type"];
|
||||
return !String.IsNullOrEmpty(contentType) &&
|
||||
contentType.Equals(FormEncodedContentType, StringComparison.OrdinalIgnoreCase);
|
||||
var contentType = request.GetContentType();
|
||||
return contentType != null &&
|
||||
contentType.ContentType.Equals(FormEncodedContentType, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static CultureInfo GetCultureInfo(HttpRequest request)
|
||||
|
|
|
|||
|
|
@ -24,11 +24,13 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Test
|
|||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetValueProvider_ReturnsValueProviderInstaceWithInvariantCulture()
|
||||
[Theory]
|
||||
[InlineData("application/x-www-form-urlencoded")]
|
||||
[InlineData("application/x-www-form-urlencoded;charset=utf-8")]
|
||||
public async Task GetValueProvider_ReturnsValueProviderInstaceWithInvariantCulture(string contentType)
|
||||
{
|
||||
// Arrange
|
||||
var requestContext = CreateRequestContext("application/x-www-form-urlencoded");
|
||||
var requestContext = CreateRequestContext(contentType);
|
||||
var factory = new FormValueProviderFactory();
|
||||
|
||||
// Act
|
||||
|
|
|
|||
Loading…
Reference in New Issue