aspnetcore/src/Microsoft.AspNet.Hosting/Builder/HttpContextFactory.cs

20 lines
773 B
C#

// 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 Microsoft.AspNet.FeatureModel;
using Microsoft.AspNet.Http;
using Microsoft.AspNet.Http.Core;
namespace Microsoft.AspNet.Hosting.Builder
{
public class HttpContextFactory : IHttpContextFactory
{
public HttpContext CreateHttpContext(object serverContext)
{
var featureObject = serverContext as IFeatureCollection ?? new FeatureObject(serverContext);
var featureCollection = new FeatureCollection(featureObject);
var httpContext = new DefaultHttpContext(featureCollection);
return httpContext;
}
}
}