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

Commit

Permalink
#542 Add IHttpConnectionFeature.ConnectionId
Browse files Browse the repository at this point in the history
  • Loading branch information
Tratcher committed Feb 18, 2016
1 parent 8c120a0 commit 5e7b30c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/Microsoft.AspNetCore.Http.Features/IHttpConnectionFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,34 @@

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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public HttpConnectionFeature()
{
}

public string ConnectionId { get; set; }

public IPAddress LocalIpAddress { get; set; }

public int LocalPort { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/Microsoft.AspNetCore.Owin/OwinConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ internal static class CommonKeys
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";
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.AspNetCore.Owin/OwinEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public OwinEnvironment(HttpContext context)
}))
},

{ 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),
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.AspNetCore.Owin/OwinFeatureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ int IHttpConnectionFeature.LocalPort
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
Expand Down

0 comments on commit 5e7b30c

Please sign in to comment.