From cb3def56683cc9e0294b5e78fb70f686be4074ee Mon Sep 17 00:00:00 2001 From: Praburaj Date: Wed, 25 Feb 2015 17:40:17 -0800 Subject: [PATCH] Changing signature of AppFunc to pass on IFeatureCollection Reaction to this fix: https://github.com/aspnet/Hosting/issues/162 --- src/Kestrel/ServerFactory.cs | 18 +++++++++++------- src/Kestrel/ServerRequest.cs | 23 +++++++++++++++++++++-- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/Kestrel/ServerFactory.cs b/src/Kestrel/ServerFactory.cs index c683d63be6..4c8997519d 100644 --- a/src/Kestrel/ServerFactory.cs +++ b/src/Kestrel/ServerFactory.cs @@ -1,10 +1,14 @@ -using Microsoft.AspNet.Hosting.Server; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System; -using Microsoft.AspNet.Builder; -using Microsoft.Framework.ConfigurationModel; -using System.Threading.Tasks; -using Microsoft.AspNet.Server.Kestrel; using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNet.Builder; +using Microsoft.AspNet.FeatureModel; +using Microsoft.AspNet.Hosting.Server; +using Microsoft.AspNet.Server.Kestrel; +using Microsoft.Framework.ConfigurationModel; using Microsoft.Framework.Runtime; namespace Kestrel @@ -28,7 +32,7 @@ namespace Kestrel return information; } - public IDisposable Start(IServerInformation serverInformation, Func application) + public IDisposable Start(IServerInformation serverInformation, Func application) { var disposables = new List(); var information = (ServerInformation)serverInformation; @@ -43,7 +47,7 @@ namespace Kestrel async frame => { var request = new ServerRequest(frame); - await application.Invoke(request); + await application.Invoke(request.Features); })); } disposables.Add(engine); diff --git a/src/Kestrel/ServerRequest.cs b/src/Kestrel/ServerRequest.cs index 3b60965b6f..d455feefad 100644 --- a/src/Kestrel/ServerRequest.cs +++ b/src/Kestrel/ServerRequest.cs @@ -1,10 +1,14 @@ -using Microsoft.AspNet.Http.Interfaces; -using Microsoft.AspNet.Server.Kestrel.Http; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; +using Microsoft.AspNet.FeatureModel; +using Microsoft.AspNet.Http.Interfaces; +using Microsoft.AspNet.Server.Kestrel.Http; namespace Kestrel { @@ -13,10 +17,25 @@ namespace Kestrel Frame _frame; string _scheme; string _pathBase; + private FeatureCollection _features; public ServerRequest(Frame frame) { _frame = frame; + _features = new FeatureCollection(); + PopulateFeatures(); + } + + private void PopulateFeatures() + { + _features.Add(typeof(IHttpRequestFeature), this); + _features.Add(typeof(IHttpResponseFeature), this); + _features.Add(typeof(IHttpUpgradeFeature), this); + } + + internal IFeatureCollection Features + { + get { return _features; } } string IHttpRequestFeature.Protocol