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

Add IHttpConnectionFeature.ConnectionId #564

Merged
merged 1 commit into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you make this up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's ok, I made up many of the other ones too :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

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