Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
Removed Cors.Core dependency from Mvc.Core
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaybhargavb committed Jun 16, 2015
1 parent fcdbd17 commit 69e051d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/Microsoft.AspNet.Mvc.Core/HttpMethodConstraint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Microsoft.AspNet.Cors.Core;
using Microsoft.Framework.Internal;

namespace Microsoft.AspNet.Mvc
Expand All @@ -16,6 +15,10 @@ public class HttpMethodConstraint : IActionConstraint

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.
public HttpMethodConstraint([NotNull] IEnumerable<string> httpMethods)
{
Expand Down Expand Up @@ -56,13 +59,13 @@ public bool Accept([NotNull] ActionConstraintContext context)

var request = context.RouteContext.HttpContext.Request;
var method = request.Method;
if (request.Headers.ContainsKey(CorsConstants.Origin))
if (request.Headers.ContainsKey(OriginHeader))
{
// 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(
request.Method,
CorsConstants.PreflightHttpMethod,
PreflightHttpMethod,
StringComparison.Ordinal) &&
accessControlRequestMethod != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ private static void ConfigureDefaultServices(IServiceCollection services)
{
services.AddOptions();
services.AddRouting();
services.AddCors();
services.AddNotifier();
services.Configure<RouteOptions>(
routeOptions => routeOptions.ConstraintMap.Add("exists", typeof(KnownRouteValueConstraint)));
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.AspNet.Mvc.Core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.Cors.Core": "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.Common": { "version": "6.0.0-*", "type": "build" },
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
Expand Down

0 comments on commit 69e051d

Please sign in to comment.