Follow common pattern for implementing IHttpRequestLifetimeFeature

This commit is contained in:
Stephen Halter 2015-11-16 15:10:30 -08:00
parent b73e42b617
commit f7a5c38f65
2 changed files with 15 additions and 3 deletions

View File

@ -231,6 +231,18 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
} }
} }
CancellationToken IHttpRequestLifetimeFeature.RequestAborted
{
get
{
return RequestAborted;
}
set
{
RequestAborted = value;
}
}
bool IHttpResponseFeature.HasStarted bool IHttpResponseFeature.HasStarted
{ {
get { return HasResponseStarted; } get { return HasResponseStarted; }
@ -263,8 +275,6 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
bool IHttpConnectionFeature.IsLocal { get; set; } bool IHttpConnectionFeature.IsLocal { get; set; }
CancellationToken IHttpRequestLifetimeFeature.RequestAborted { get; set; }
object IFeatureCollection.this[Type key] object IFeatureCollection.this[Type key]
{ {
get { return FastFeatureGet(key); } get { return FastFeatureGet(key); }

View File

@ -89,6 +89,8 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
public Stream DuplexStream { get; set; } public Stream DuplexStream { get; set; }
public CancellationToken RequestAborted { get; set; }
public bool HasResponseStarted public bool HasResponseStarted
{ {
get { return _responseStarted; } get { return _responseStarted; }
@ -241,7 +243,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
DuplexStream = new FrameDuplexStream(RequestBody, ResponseBody); DuplexStream = new FrameDuplexStream(RequestBody, ResponseBody);
_requestAbortCts = CancellationTokenSource.CreateLinkedTokenSource(_disconnectCts.Token); _requestAbortCts = CancellationTokenSource.CreateLinkedTokenSource(_disconnectCts.Token);
((IHttpRequestLifetimeFeature)this).RequestAborted = _requestAbortCts.Token; RequestAborted = _requestAbortCts.Token;
var httpContext = HttpContextFactory.Create(this); var httpContext = HttpContextFactory.Create(this);
try try