#542 Add IHttpConnectionFeature.ConnectionId

This commit is contained in:
Chris R 2016-02-11 14:21:47 -08:00
parent 8c120a0792
commit 5e7b30c04b
5 changed files with 35 additions and 0 deletions

View File

@ -5,11 +5,34 @@ using System.Net;
namespace Microsoft.AspNetCore.Http.Features
{
/// <summary>
/// Information regarding the TCP/IP connection carrying the request.
/// </summary>
public interface IHttpConnectionFeature
{
/// <summary>
/// The unique identifier for the connection the request was received on. This is primarily for diagnostic purposes.
/// </summary>
string ConnectionId { get; set; }
/// <summary>
/// The IPAddress of the client making the request. Note this may be for a proxy rather than the end user.
/// </summary>
IPAddress RemoteIpAddress { get; set; }
/// <summary>
/// The local IPAddress on which the request was received.
/// </summary>
IPAddress LocalIpAddress { get; set; }
/// <summary>
/// The remote port of the client making the request.
/// </summary>
int RemotePort { get; set; }
/// <summary>
/// The local port on which the request was received.
/// </summary>
int LocalPort { get; set; }
}
}

View File

@ -11,6 +11,8 @@ namespace Microsoft.AspNetCore.Http.Features.Internal
{
}
public string ConnectionId { get; set; }
public IPAddress LocalIpAddress { get; set; }
public int LocalPort { get; set; }

View File

@ -73,6 +73,7 @@ namespace Microsoft.AspNetCore.Owin
public const string RemotePort = "server.RemotePort";
public const string LocalIpAddress = "server.LocalIpAddress";
public const string LocalPort = "server.LocalPort";
public const string ConnectionId = "server.ConnectionId";
public const string TraceOutput = "host.TraceOutput";
public const string Addresses = "host.Addresses";
public const string AppName = "host.AppName";

View File

@ -74,6 +74,9 @@ namespace Microsoft.AspNetCore.Owin
}))
},
{ OwinConstants.CommonKeys.ConnectionId, new FeatureMap<IHttpConnectionFeature>(feature => feature.ConnectionId,
(feature, value) => feature.ConnectionId = Convert.ToString(value, CultureInfo.InvariantCulture)) },
{ OwinConstants.CommonKeys.LocalPort, new FeatureMap<IHttpConnectionFeature>(feature => feature.LocalPort.ToString(CultureInfo.InvariantCulture),
(feature, value) => feature.LocalPort = Convert.ToInt32(value, CultureInfo.InvariantCulture)) },
{ OwinConstants.CommonKeys.RemotePort, new FeatureMap<IHttpConnectionFeature>(feature => feature.RemotePort.ToString(CultureInfo.InvariantCulture),

View File

@ -190,6 +190,12 @@ namespace Microsoft.AspNetCore.Owin
set { Prop(OwinConstants.CommonKeys.LocalPort, value.ToString(CultureInfo.InvariantCulture)); }
}
string IHttpConnectionFeature.ConnectionId
{
get { return Prop<string>(OwinConstants.CommonKeys.ConnectionId); }
set { Prop(OwinConstants.CommonKeys.ConnectionId, value); }
}
private bool SupportsSendFile
{
get