parent
66613b194d
commit
5dcb568df0
|
|
@ -31,6 +31,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// <summary>
|
||||
/// Verifies the HTTP request method is CONNECT.
|
||||
/// <summary/>
|
||||
/// <param name="method">HTTP request method.</param>
|
||||
public static bool IsConnect(string method)
|
||||
{
|
||||
return object.ReferenceEquals(Connect, method) || StringComparer.OrdinalIgnoreCase.Equals(Connect, method);
|
||||
|
|
@ -39,6 +40,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// <summary>
|
||||
/// Verifies the HTTP request method is DELETE.
|
||||
/// <summary/>
|
||||
/// <param name="method">HTTP request method.</param>
|
||||
public static bool IsDelete(string method)
|
||||
{
|
||||
return object.ReferenceEquals(Delete, method) || StringComparer.OrdinalIgnoreCase.Equals(Delete, method);
|
||||
|
|
@ -47,6 +49,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// <summary>
|
||||
/// Verifies the HTTP request method is GET.
|
||||
/// <summary/>
|
||||
/// <param name="method">HTTP request method.</param>
|
||||
public static bool IsGet(string method)
|
||||
{
|
||||
return object.ReferenceEquals(Get, method) || StringComparer.OrdinalIgnoreCase.Equals(Get, method);
|
||||
|
|
@ -55,6 +58,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// <summary>
|
||||
/// Verifies the HTTP request method is HEAD.
|
||||
/// <summary/>
|
||||
/// <param name="method">HTTP request method.</param>
|
||||
public static bool IsHead(string method)
|
||||
{
|
||||
return object.ReferenceEquals(Head, method) || StringComparer.OrdinalIgnoreCase.Equals(Head, method);
|
||||
|
|
@ -63,6 +67,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// <summary>
|
||||
/// Verifies the HTTP request method is OPTIONS.
|
||||
/// <summary/>
|
||||
/// <param name="method">HTTP request method.</param>
|
||||
public static bool IsOptions(string method)
|
||||
{
|
||||
return object.ReferenceEquals(Options, method) || StringComparer.OrdinalIgnoreCase.Equals(Options, method);
|
||||
|
|
@ -71,6 +76,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// <summary>
|
||||
/// Verifies the HTTP request method is PATCH.
|
||||
/// <summary/>
|
||||
/// <param name="method">HTTP request method.</param>
|
||||
public static bool IsPatch(string method)
|
||||
{
|
||||
return object.ReferenceEquals(Patch, method) || StringComparer.OrdinalIgnoreCase.Equals(Patch, method);
|
||||
|
|
@ -79,6 +85,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// <summary>
|
||||
/// Verifies the HTTP request method is POST.
|
||||
/// <summary/>
|
||||
/// <param name="method">HTTP request method.</param>
|
||||
public static bool IsPost(string method)
|
||||
{
|
||||
return object.ReferenceEquals(Post, method) || StringComparer.OrdinalIgnoreCase.Equals(Post, method);
|
||||
|
|
@ -87,6 +94,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// <summary>
|
||||
/// Verifies the HTTP request method is PUT.
|
||||
/// <summary/>
|
||||
/// <param name="method">HTTP request method.</param>
|
||||
public static bool IsPut(string method)
|
||||
{
|
||||
return object.ReferenceEquals(Put, method) || StringComparer.OrdinalIgnoreCase.Equals(Put, method);
|
||||
|
|
@ -95,6 +103,7 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// <summary>
|
||||
/// Verifies the HTTP request method is TRACE.
|
||||
/// <summary/>
|
||||
/// <param name="method">HTTP request method.</param>
|
||||
public static bool IsTrace(string method)
|
||||
{
|
||||
return object.ReferenceEquals(Trace, method) || StringComparer.OrdinalIgnoreCase.Equals(Trace, method);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
namespace Microsoft.AspNetCore.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an implementation of the HTTP Context class with HTTP-specific information for a request.
|
||||
/// Represents an implementation of the HTTP Context class.
|
||||
/// <summary/>
|
||||
public sealed class DefaultHttpContext : HttpContext
|
||||
{
|
||||
|
|
@ -47,8 +47,9 @@ namespace Microsoft.AspNetCore.Http
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DefaultHttpContext class with the using a collection of AspNetCore.Http.Features.
|
||||
/// Initializes a new instance of the DefaultHttpContext class with options passed in.
|
||||
/// <summary/>
|
||||
/// <param name="features">Options to set when instantianting the Default HTTP context object.</param>
|
||||
public DefaultHttpContext(IFeatureCollection features)
|
||||
{
|
||||
_features.Initalize(features);
|
||||
|
|
@ -57,8 +58,9 @@ namespace Microsoft.AspNetCore.Http
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the current instant of the class with the using a collection of AspNetCore.Http.Features.
|
||||
/// Initialize the current instant of the class with options passed in.
|
||||
/// <summary/>
|
||||
/// <param name="features">Options to initialize the Default HTTP context object.</param>
|
||||
public void Initialize(IFeatureCollection features)
|
||||
{
|
||||
var revision = features.Revision;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using System.Threading;
|
|||
namespace Microsoft.AspNetCore.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the properties and methods used to keep access the current HTTP context.
|
||||
/// Represents the properties and methods used to access the current HTTP context.
|
||||
/// <summary/>
|
||||
public class HttpContextAccessor : IHttpContextAccessor
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ using Microsoft.Extensions.Options;
|
|||
|
||||
namespace Microsoft.AspNetCore.Http
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents methods used to create an HTTP context object.
|
||||
/// <summary/>
|
||||
[Obsolete("This is obsolete and will be removed in a future version. Use DefaultHttpContextFactory instead.")]
|
||||
public class HttpContextFactory : IHttpContextFactory
|
||||
{
|
||||
|
|
@ -15,21 +18,41 @@ namespace Microsoft.AspNetCore.Http
|
|||
private readonly FormOptions _formOptions;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the HttpContext class with options passed in.
|
||||
/// <summary/>
|
||||
/// <param name="formOptions">Options to set when instantianting the HTTP context object.</param>
|
||||
public HttpContextFactory(IOptions<FormOptions> formOptions)
|
||||
: this(formOptions, serviceScopeFactory: null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DefaultHttpContext class with options passed in.
|
||||
/// <summary/>
|
||||
/// <param name="formOptions">Options to set when instantianting the HTTP context object.</param>
|
||||
/// <param name="serviceScopeFactory">Factory object used to create the service scope for the HTTP context.</param>
|
||||
public HttpContextFactory(IOptions<FormOptions> formOptions, IServiceScopeFactory serviceScopeFactory)
|
||||
: this(formOptions, serviceScopeFactory, httpContextAccessor: null)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DefaultHttpContext class with options passed in.
|
||||
/// <summary/>
|
||||
/// <param name="formOptions">Options to set when instantianting the HTTP context object.</param>
|
||||
/// <param name="httpContextAccessor">Object to be used to access the HTTP context instance.</param>
|
||||
public HttpContextFactory(IOptions<FormOptions> formOptions, IHttpContextAccessor httpContextAccessor)
|
||||
: this(formOptions, serviceScopeFactory: null, httpContextAccessor: httpContextAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DefaultHttpContext class with options passed in.
|
||||
/// <summary/>
|
||||
/// <param name="formOptions">Options to set when instantianting the HTTP context object.</param>
|
||||
/// <param name="serviceScopeFactory">Factory object used to create the service scope for the HTTP context.</param>
|
||||
/// <param name="httpContextAccessor">Options to set when instantianting the Default HTTP context object.</param>
|
||||
public HttpContextFactory(IOptions<FormOptions> formOptions, IServiceScopeFactory serviceScopeFactory, IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
if (formOptions == null)
|
||||
|
|
@ -47,6 +70,10 @@ namespace Microsoft.AspNetCore.Http
|
|||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the DefaultHttpContext class with options passed in.
|
||||
/// <summary/>
|
||||
/// <param name="featureCollection">Options to set when instantianting the Default HTTP context object.</param>
|
||||
public HttpContext Create(IFeatureCollection featureCollection)
|
||||
{
|
||||
if (featureCollection == null)
|
||||
|
|
@ -66,6 +93,10 @@ namespace Microsoft.AspNetCore.Http
|
|||
return httpContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the HTTP context object to null for garbage collection.
|
||||
/// <summary/>
|
||||
/// <param name="httpContext">HTTP context to dispose.</param>
|
||||
public void Dispose(HttpContext httpContext)
|
||||
{
|
||||
if (_httpContextAccessor != null)
|
||||
|
|
|
|||
Loading…
Reference in New Issue