Removed Cors.Core dependency from Mvc.Core
This commit is contained in:
parent
fcdbd17e58
commit
69e051dab7
|
|
@ -5,7 +5,6 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNet.Cors.Core;
|
|
||||||
using Microsoft.Framework.Internal;
|
using Microsoft.Framework.Internal;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
|
@ -16,6 +15,10 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
private readonly IReadOnlyList<string> _methods;
|
private readonly IReadOnlyList<string> _methods;
|
||||||
|
|
||||||
|
private readonly string OriginHeader = "Origin";
|
||||||
|
private readonly string AccessControlRequestMethod = "Access-Control-Request-Method";
|
||||||
|
private readonly string PreflightHttpMethod = "OPTIONS";
|
||||||
|
|
||||||
// Empty collection means any method will be accepted.
|
// Empty collection means any method will be accepted.
|
||||||
public HttpMethodConstraint([NotNull] IEnumerable<string> httpMethods)
|
public HttpMethodConstraint([NotNull] IEnumerable<string> httpMethods)
|
||||||
{
|
{
|
||||||
|
|
@ -56,13 +59,13 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
var request = context.RouteContext.HttpContext.Request;
|
var request = context.RouteContext.HttpContext.Request;
|
||||||
var method = request.Method;
|
var method = request.Method;
|
||||||
if (request.Headers.ContainsKey(CorsConstants.Origin))
|
if (request.Headers.ContainsKey(OriginHeader))
|
||||||
{
|
{
|
||||||
// Update the http method if it is preflight request.
|
// Update the http method if it is preflight request.
|
||||||
var accessControlRequestMethod = request.Headers.Get(CorsConstants.AccessControlRequestMethod);
|
var accessControlRequestMethod = request.Headers.Get(AccessControlRequestMethod);
|
||||||
if (string.Equals(
|
if (string.Equals(
|
||||||
request.Method,
|
request.Method,
|
||||||
CorsConstants.PreflightHttpMethod,
|
PreflightHttpMethod,
|
||||||
StringComparison.Ordinal) &&
|
StringComparison.Ordinal) &&
|
||||||
accessControlRequestMethod != null)
|
accessControlRequestMethod != null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -152,7 +152,6 @@ namespace Microsoft.Framework.DependencyInjection
|
||||||
{
|
{
|
||||||
services.AddOptions();
|
services.AddOptions();
|
||||||
services.AddRouting();
|
services.AddRouting();
|
||||||
services.AddCors();
|
|
||||||
services.AddNotifier();
|
services.AddNotifier();
|
||||||
services.Configure<RouteOptions>(
|
services.Configure<RouteOptions>(
|
||||||
routeOptions => routeOptions.ConstraintMap.Add("exists", typeof(KnownRouteValueConstraint)));
|
routeOptions => routeOptions.ConstraintMap.Add("exists", typeof(KnownRouteValueConstraint)));
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
"warningsAsErrors": true
|
"warningsAsErrors": true
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.AspNet.Cors.Core": "1.0.0-*",
|
|
||||||
"Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*",
|
"Microsoft.AspNet.Hosting.Abstractions": "1.0.0-*",
|
||||||
|
"Microsoft.AspNet.Http": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Mvc.Abstractions": "6.0.0-*",
|
"Microsoft.AspNet.Mvc.Abstractions": "6.0.0-*",
|
||||||
"Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" },
|
"Microsoft.AspNet.Mvc.Common": { "version": "6.0.0-*", "type": "build" },
|
||||||
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
|
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue