Merge pull request #142 from priyanshu92/fix-duplicate-header-names

Fix duplicate header names
This commit is contained in:
Artak Mkrtchyan 2018-02-07 15:30:58 -08:00 committed by GitHub
commit 7969a8dddc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 23 deletions

View File

@ -1,6 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Http;
using Microsoft.Net.Http.Headers;
namespace Microsoft.AspNetCore.Cors.Infrastructure namespace Microsoft.AspNetCore.Cors.Infrastructure
{ {
/// <summary> /// <summary>
@ -11,12 +14,12 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure
/// <summary> /// <summary>
/// The HTTP method for the CORS preflight request. /// The HTTP method for the CORS preflight request.
/// </summary> /// </summary>
public static readonly string PreflightHttpMethod = "OPTIONS"; public static readonly string PreflightHttpMethod = HttpMethods.Options;
/// <summary> /// <summary>
/// The Origin request header. /// The Origin request header.
/// </summary> /// </summary>
public static readonly string Origin = "Origin"; public static readonly string Origin = HeaderNames.Origin;
/// <summary> /// <summary>
/// The value for the Access-Control-Allow-Origin response header to allow all origins. /// The value for the Access-Control-Allow-Origin response header to allow all origins.
@ -26,66 +29,67 @@ namespace Microsoft.AspNetCore.Cors.Infrastructure
/// <summary> /// <summary>
/// The Access-Control-Request-Method request header. /// The Access-Control-Request-Method request header.
/// </summary> /// </summary>
public static readonly string AccessControlRequestMethod = "Access-Control-Request-Method"; public static readonly string AccessControlRequestMethod = HeaderNames.AccessControlRequestMethod;
/// <summary> /// <summary>
/// The Access-Control-Request-Headers request header. /// The Access-Control-Request-Headers request header.
/// </summary> /// </summary>
public static readonly string AccessControlRequestHeaders = "Access-Control-Request-Headers"; public static readonly string AccessControlRequestHeaders = HeaderNames.AccessControlRequestHeaders;
/// <summary> /// <summary>
/// The Access-Control-Allow-Origin response header. /// The Access-Control-Allow-Origin response header.
/// </summary> /// </summary>
public static readonly string AccessControlAllowOrigin = "Access-Control-Allow-Origin"; public static readonly string AccessControlAllowOrigin = HeaderNames.AccessControlAllowOrigin;
/// <summary> /// <summary>
/// The Access-Control-Allow-Headers response header. /// The Access-Control-Allow-Headers response header.
/// </summary> /// </summary>
public static readonly string AccessControlAllowHeaders = "Access-Control-Allow-Headers"; public static readonly string AccessControlAllowHeaders = HeaderNames.AccessControlAllowHeaders;
/// <summary> /// <summary>
/// The Access-Control-Expose-Headers response header. /// The Access-Control-Expose-Headers response header.
/// </summary> /// </summary>
public static readonly string AccessControlExposeHeaders = "Access-Control-Expose-Headers"; public static readonly string AccessControlExposeHeaders = HeaderNames.AccessControlExposeHeaders;
/// <summary> /// <summary>
/// The Access-Control-Allow-Methods response header. /// The Access-Control-Allow-Methods response header.
/// </summary> /// </summary>
public static readonly string AccessControlAllowMethods = "Access-Control-Allow-Methods"; public static readonly string AccessControlAllowMethods = HeaderNames.AccessControlAllowMethods;
/// <summary> /// <summary>
/// The Access-Control-Allow-Credentials response header. /// The Access-Control-Allow-Credentials response header.
/// </summary> /// </summary>
public static readonly string AccessControlAllowCredentials = "Access-Control-Allow-Credentials"; public static readonly string AccessControlAllowCredentials = HeaderNames.AccessControlAllowCredentials;
/// <summary> /// <summary>
/// The Access-Control-Max-Age response header. /// The Access-Control-Max-Age response header.
/// </summary> /// </summary>
public static readonly string AccessControlMaxAge = "Access-Control-Max-Age"; public static readonly string AccessControlMaxAge = HeaderNames.AccessControlMaxAge;
internal static readonly string[] SimpleRequestHeaders = internal static readonly string[] SimpleRequestHeaders =
{ {
"Origin", HeaderNames.Origin,
"Accept", HeaderNames.Accept,
"Accept-Language", HeaderNames.AcceptLanguage,
"Content-Language", HeaderNames.ContentLanguage,
}; };
internal static readonly string[] SimpleResponseHeaders = internal static readonly string[] SimpleResponseHeaders =
{ {
"Cache-Control", HeaderNames.CacheControl,
"Content-Language", HeaderNames.ContentLanguage,
"Content-Type", HeaderNames.ContentType,
"Expires", HeaderNames.Expires,
"Last-Modified", HeaderNames.LastModified,
"Pragma" HeaderNames.Pragma
}; };
internal static readonly string[] SimpleMethods = internal static readonly string[] SimpleMethods =
{ {
"GET", HttpMethods.Get,
"HEAD", HttpMethods.Head,
"POST" HttpMethods.Post
}; };
} }
} }