Reset connection info not using interface

This commit is contained in:
Ben Adams 2016-05-19 00:56:50 +01:00
parent 925d8e0200
commit 6098880132
2 changed files with 36 additions and 13 deletions

View File

@ -11,7 +11,6 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Server.Kestrel.Http
@ -265,15 +264,35 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
int IFeatureCollection.Revision => _featureRevision;
IPAddress IHttpConnectionFeature.RemoteIpAddress { get; set; }
IPAddress IHttpConnectionFeature.RemoteIpAddress
{
get { return RemoteIpAddress; }
set { RemoteIpAddress = value; }
}
IPAddress IHttpConnectionFeature.LocalIpAddress { get; set; }
IPAddress IHttpConnectionFeature.LocalIpAddress
{
get { return LocalIpAddress; }
set { LocalIpAddress = value; }
}
int IHttpConnectionFeature.RemotePort { get; set; }
int IHttpConnectionFeature.RemotePort
{
get { return RemotePort; }
set { RemotePort = value; }
}
int IHttpConnectionFeature.LocalPort { get; set; }
int IHttpConnectionFeature.LocalPort
{
get { return LocalPort; }
set { LocalPort = value; }
}
string IHttpConnectionFeature.ConnectionId { get; set; }
string IHttpConnectionFeature.ConnectionId
{
get { return ConnectionIdFeature; }
set { ConnectionIdFeature = value; }
}
object IFeatureCollection.this[Type key]
{

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Numerics;
using System.Text;
using System.Threading;
@ -74,6 +75,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
Reset();
}
public string ConnectionIdFeature { get; set; }
public IPAddress RemoteIpAddress { get; set; }
public int RemotePort { get; set; }
public IPAddress LocalIpAddress { get; set; }
public int LocalPort { get; set; }
public string Scheme { get; set; }
public string Method { get; set; }
public string RequestUri { get; set; }
@ -241,14 +247,12 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http
StatusCode = 200;
ReasonPhrase = null;
var httpConnectionFeature = this as IHttpConnectionFeature;
httpConnectionFeature.RemoteIpAddress = RemoteEndPoint?.Address;
httpConnectionFeature.RemotePort = RemoteEndPoint?.Port ?? 0;
RemoteIpAddress = RemoteEndPoint?.Address;
RemotePort = RemoteEndPoint?.Port ?? 0;
httpConnectionFeature.LocalIpAddress = LocalEndPoint?.Address;
httpConnectionFeature.LocalPort = LocalEndPoint?.Port ?? 0;
httpConnectionFeature.ConnectionId = ConnectionId;
LocalIpAddress = LocalEndPoint?.Address;
LocalPort = LocalEndPoint?.Port ?? 0;
ConnectionIdFeature = ConnectionId;
PrepareRequest?.Invoke(this);