Changing signature of AppFunc to pass on IFeatureCollection

Reaction to this fix: https://github.com/aspnet/Hosting/issues/162
This commit is contained in:
Praburaj 2015-02-25 17:40:17 -08:00
parent 0da745439c
commit cb3def5668
2 changed files with 32 additions and 9 deletions

View File

@ -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<object, Task> application)
public IDisposable Start(IServerInformation serverInformation, Func<IFeatureCollection, Task> application)
{
var disposables = new List<IDisposable>();
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);

View File

@ -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