diff --git a/src/Http/Http.Abstractions/src/HttpMethods.cs b/src/Http/Http.Abstractions/src/HttpMethods.cs index 05a5f2e834..6a3fc6aff3 100644 --- a/src/Http/Http.Abstractions/src/HttpMethods.cs +++ b/src/Http/Http.Abstractions/src/HttpMethods.cs @@ -5,12 +5,15 @@ using System; namespace Microsoft.AspNetCore.Http { + /// + /// Contains methods to verify the request method of an HTTP request. + /// public static class HttpMethods { // We are intentionally using 'static readonly' here instead of 'const'. - // 'const' values would be embedded in to each assembly that used them + // 'const' values would be embedded into each assembly that used them // and each consuming assembly would have a different 'string' instance. - // Using .'static readonly' means that all consumers get thee exact same + // Using .'static readonly' means that all consumers get these exact same // 'string' instance, which means the 'ReferenceEquals' checks below work // and allow us to optimize comparisons when these constants are used. @@ -25,46 +28,73 @@ namespace Microsoft.AspNetCore.Http public static readonly string Put = "PUT"; public static readonly string Trace = "TRACE"; + /// + /// Verifies the HTTP request method is CONNECT. + /// public static bool IsConnect(string method) { return object.ReferenceEquals(Connect, method) || StringComparer.OrdinalIgnoreCase.Equals(Connect, method); } + /// + /// Verifies the HTTP request method is DELETE. + /// public static bool IsDelete(string method) { return object.ReferenceEquals(Delete, method) || StringComparer.OrdinalIgnoreCase.Equals(Delete, method); } + /// + /// Verifies the HTTP request method is GET. + /// public static bool IsGet(string method) { return object.ReferenceEquals(Get, method) || StringComparer.OrdinalIgnoreCase.Equals(Get, method); } + /// + /// Verifies the HTTP request method is HEAD. + /// public static bool IsHead(string method) { return object.ReferenceEquals(Head, method) || StringComparer.OrdinalIgnoreCase.Equals(Head, method); } + /// + /// Verifies the HTTP request method is OPTIONS. + /// public static bool IsOptions(string method) { return object.ReferenceEquals(Options, method) || StringComparer.OrdinalIgnoreCase.Equals(Options, method); } + /// + /// Verifies the HTTP request method is PATCH. + /// public static bool IsPatch(string method) { return object.ReferenceEquals(Patch, method) || StringComparer.OrdinalIgnoreCase.Equals(Patch, method); } + /// + /// Verifies the HTTP request method is POST. + /// public static bool IsPost(string method) { return object.ReferenceEquals(Post, method) || StringComparer.OrdinalIgnoreCase.Equals(Post, method); } + /// + /// Verifies the HTTP request method is PUT. + /// public static bool IsPut(string method) { return object.ReferenceEquals(Put, method) || StringComparer.OrdinalIgnoreCase.Equals(Put, method); } + /// + /// Verifies the HTTP request method is TRACE. + /// public static bool IsTrace(string method) { return object.ReferenceEquals(Trace, method) || StringComparer.OrdinalIgnoreCase.Equals(Trace, method); diff --git a/src/Http/Http/src/DefaultHttpContext.cs b/src/Http/Http/src/DefaultHttpContext.cs index 7d096f186a..73f932746e 100644 --- a/src/Http/Http/src/DefaultHttpContext.cs +++ b/src/Http/Http/src/DefaultHttpContext.cs @@ -13,6 +13,9 @@ using Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Http { + /// + /// Represents an implementation of the HTTP Context class with HTTP-specific information for a request. + /// public sealed class DefaultHttpContext : HttpContext { // Lambdas hoisted to static readonly fields to improve inlining https://github.com/dotnet/roslyn/issues/13624 @@ -32,6 +35,9 @@ namespace Microsoft.AspNetCore.Http private DefaultConnectionInfo _connection; private DefaultWebSocketManager _websockets; + /// + /// Initializes a new instance of the DefaultHttpContext class. + /// public DefaultHttpContext() : this(new FeatureCollection()) { @@ -40,6 +46,9 @@ namespace Microsoft.AspNetCore.Http Features.Set(new StreamResponseBodyFeature(Stream.Null)); } + /// + /// Initializes a new instance of the DefaultHttpContext class with the using a collection of AspNetCore.Http.Features. + /// public DefaultHttpContext(IFeatureCollection features) { _features.Initalize(features); @@ -47,6 +56,9 @@ namespace Microsoft.AspNetCore.Http _response = new DefaultHttpResponse(this); } + /// + /// Initialize the current instant of the class with the using a collection of AspNetCore.Http.Features. + /// public void Initialize(IFeatureCollection features) { var revision = features.Revision; @@ -57,6 +69,9 @@ namespace Microsoft.AspNetCore.Http _websockets?.Initialize(features, revision); } + /// + /// Uninitialize the child request, response, connection and websocket object features and reset the class instance features. + /// public void Uninitialize() { _features = default; @@ -66,8 +81,14 @@ namespace Microsoft.AspNetCore.Http _websockets?.Uninitialize(); } + /// + /// Gets or set the FormOptions for this instance. + /// public FormOptions FormOptions { get; set; } + /// + /// Gets or sets the IServiceScopeFactory for this instance. + /// public IServiceScopeFactory ServiceScopeFactory { get; set; } private IItemsFeature ItemsFeature => @@ -92,16 +113,43 @@ namespace Microsoft.AspNetCore.Http private IHttpRequestIdentifierFeature RequestIdentifierFeature => _features.Fetch(ref _features.Cache.RequestIdentifier, _newHttpRequestIdentifierFeature); + /// + /// Returns the Features for this instance. If null, an ObjectDisposedException Exceptioon is thrown. + /// public override IFeatureCollection Features => _features.Collection ?? ContextDisposed(); + /// + /// Returns the HttpRequest of this instance. + /// public override HttpRequest Request => _request; + /// + /// Returns the HttpResponse of this instance. + /// public override HttpResponse Response => _response; + /// + /// Returns the connection information of this instance. + /// + /// + /// If the Connection is null, a new DefaultConnectionInfo object is instantiated using the Features collection of this instance. + /// public override ConnectionInfo Connection => _connection ?? (_connection = new DefaultConnectionInfo(Features)); + /// + /// Returns the Web Socket Manager of this instance. + /// + /// + /// If the Connection is null, a new DefaultWebSocketManager object is instantiated using the Features collection of this instance. + /// public override WebSocketManager WebSockets => _websockets ?? (_websockets = new DefaultWebSocketManager(Features)); + /// + /// Gets or sets the claims principal of this instance. + /// + /// + /// If the ClaimsPrincipal object is null, a new ClaimsPrincipal object is instantiated. + /// public override ClaimsPrincipal User { get @@ -117,30 +165,48 @@ namespace Microsoft.AspNetCore.Http set { HttpAuthenticationFeature.User = value; } } + /// + /// Gets or sets the item feature object(s) of this instance. + /// public override IDictionary Items { get { return ItemsFeature.Items; } set { ItemsFeature.Items = value; } } + /// + /// Gets or sets the service provider feature object of this instance. + /// public override IServiceProvider RequestServices { get { return ServiceProvidersFeature.RequestServices; } set { ServiceProvidersFeature.RequestServices = value; } } + /// + /// Gets or sets the cancellation token object of this instance. + /// public override CancellationToken RequestAborted { get { return LifetimeFeature.RequestAborted; } set { LifetimeFeature.RequestAborted = value; } } + /// + /// Gets or sets the trace identifier of this instance. + /// public override string TraceIdentifier { get { return RequestIdentifierFeature.TraceIdentifier; } set { RequestIdentifierFeature.TraceIdentifier = value; } } + /// + /// Gets or sets the session of this instance. + /// + /// + /// If session feature has not been set, an Invalid Operation Exception is thrown. + /// public override ISession Session { get diff --git a/src/Http/Http/src/HttpContextAccessor.cs b/src/Http/Http/src/HttpContextAccessor.cs index 286151029c..d99e02ef88 100644 --- a/src/Http/Http/src/HttpContextAccessor.cs +++ b/src/Http/Http/src/HttpContextAccessor.cs @@ -5,10 +5,16 @@ using System.Threading; namespace Microsoft.AspNetCore.Http { + /// + /// Represents the properties and methods used to keep access the current HTTP context. + /// public class HttpContextAccessor : IHttpContextAccessor { private static AsyncLocal _httpContextCurrent = new AsyncLocal(); + /// + /// Gets or sets the HTTP context. + /// public HttpContext HttpContext { get diff --git a/src/Middleware/HttpsPolicy/src/HttpsRedirectionMiddleware.cs b/src/Middleware/HttpsPolicy/src/HttpsRedirectionMiddleware.cs index e20e8b8a33..e2926593e2 100644 --- a/src/Middleware/HttpsPolicy/src/HttpsRedirectionMiddleware.cs +++ b/src/Middleware/HttpsPolicy/src/HttpsRedirectionMiddleware.cs @@ -13,6 +13,9 @@ using Microsoft.Net.Http.Headers; namespace Microsoft.AspNetCore.HttpsPolicy { + /// + /// Provides functionality to redirect client requests to an address that uses the HTTPS protocol. + /// public class HttpsRedirectionMiddleware { private const int PortNotFound = -1; @@ -26,7 +29,7 @@ namespace Microsoft.AspNetCore.HttpsPolicy private readonly ILogger _logger; /// - /// Initializes the HttpsRedirectionMiddleware + /// Initializes the HttpsRedirectionMiddleware. /// /// /// @@ -56,7 +59,7 @@ namespace Microsoft.AspNetCore.HttpsPolicy } /// - /// Initializes the HttpsRedirectionMiddleware + /// Initializes the HttpsRedirectionMiddleware. /// /// /// diff --git a/src/Middleware/HttpsPolicy/src/HttpsRedirectionOptions.cs b/src/Middleware/HttpsPolicy/src/HttpsRedirectionOptions.cs index 07a166c162..85e177ec25 100644 --- a/src/Middleware/HttpsPolicy/src/HttpsRedirectionOptions.cs +++ b/src/Middleware/HttpsPolicy/src/HttpsRedirectionOptions.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.HttpsPolicy { /// - /// Options for the HttpsRedirection middleware + /// Options for the HttpsRedirection middleware. /// public class HttpsRedirectionOptions { diff --git a/src/Servers/HttpSys/src/WebHostBuilderHttpSysExtensions.cs b/src/Servers/HttpSys/src/WebHostBuilderHttpSysExtensions.cs index 7b4caaef62..f62a0982b6 100644 --- a/src/Servers/HttpSys/src/WebHostBuilderHttpSysExtensions.cs +++ b/src/Servers/HttpSys/src/WebHostBuilderHttpSysExtensions.cs @@ -9,6 +9,9 @@ using Microsoft.Extensions.Options; namespace Microsoft.AspNetCore.Hosting { + /// + /// Provides extensions method to use Http.sys as the server for the web host. + /// public static class WebHostBuilderHttpSysExtensions { ///