Remove temp IAppBuilder support.
This commit is contained in:
parent
c31e0f295f
commit
f12117fe1f
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30410.0
|
||||
VisualStudioVersion = 12.0.30401.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{A5A15F1C-885A-452A-A731-B0173DDBD913}"
|
||||
EndProject
|
||||
|
|
@ -17,8 +17,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.FeatureMod
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.PipelineCore.Tests", "test\Microsoft.AspNet.PipelineCore.Tests\Microsoft.AspNet.PipelineCore.Tests.kproj", "{AA99AF26-F7B1-4A6B-A922-5C25539F6391}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.AppBuilderSupport", "src\Microsoft.AspNet.AppBuilderSupport\Microsoft.AspNet.AppBuilderSupport.kproj", "{65C93D2B-CBD1-4E51-9312-10C1965A7241}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.FeatureModel.Tests", "test\Microsoft.AspNet.FeatureModel.Tests\Microsoft.AspNet.FeatureModel.Tests.kproj", "{C5D2BAE1-E182-48A0-AA74-1AF14B782BF7}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Abstractions.Tests", "test\Microsoft.AspNet.Abstractions.Tests\Microsoft.AspNet.Abstractions.Tests.kproj", "{F16692B8-9F38-4DCA-A582-E43172B989C6}"
|
||||
|
|
@ -85,16 +83,6 @@ Global
|
|||
{AA99AF26-F7B1-4A6B-A922-5C25539F6391}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{AA99AF26-F7B1-4A6B-A922-5C25539F6391}.Release|x86.ActiveCfg = Release|x86
|
||||
{AA99AF26-F7B1-4A6B-A922-5C25539F6391}.Release|x86.Build.0 = Release|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Debug|x86.Build.0 = Debug|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Release|Mixed Platforms.ActiveCfg = Release|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Release|x86.ActiveCfg = Release|x86
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241}.Release|x86.Build.0 = Release|x86
|
||||
{C5D2BAE1-E182-48A0-AA74-1AF14B782BF7}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{C5D2BAE1-E182-48A0-AA74-1AF14B782BF7}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{C5D2BAE1-E182-48A0-AA74-1AF14B782BF7}.Debug|Mixed Platforms.Build.0 = Debug|x86
|
||||
|
|
@ -135,7 +123,6 @@ Global
|
|||
{D9128247-8F97-48B8-A863-F1F21A029FCE} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
|
||||
{32A4C918-30EE-41DB-8E26-8A3BB88ED231} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
|
||||
{AA99AF26-F7B1-4A6B-A922-5C25539F6391} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
|
||||
{65C93D2B-CBD1-4E51-9312-10C1965A7241} = {A5A15F1C-885A-452A-A731-B0173DDBD913}
|
||||
{C5D2BAE1-E182-48A0-AA74-1AF14B782BF7} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
|
||||
{F16692B8-9F38-4DCA-A582-E43172B989C6} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
|
||||
{83D44696-C790-4356-9187-79F89010ED4F} = {F31FF137-390C-49BF-A3BD-7C6ED3597C21}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
using Microsoft.AspNet.Abstractions;
|
||||
using Microsoft.AspNet.PipelineCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.FeatureModel;
|
||||
using Microsoft.AspNet.PipelineCore.Owin;
|
||||
|
||||
namespace Owin
|
||||
{
|
||||
using AppFunc = Func<IDictionary<string, object>, Task>;
|
||||
|
||||
public static class AppBuilderSupportExtensions
|
||||
{
|
||||
public static IAppBuilder UseBuilder(this IAppBuilder appBuilder, Action<IBuilder> configuration)
|
||||
{
|
||||
IBuilder builder = new Builder(null);
|
||||
configuration(builder);
|
||||
Func<AppFunc,AppFunc> middleware1 = next1 => {
|
||||
Func<RequestDelegate,RequestDelegate> middleware2 = next2 => {
|
||||
return httpContext => {
|
||||
return next1(httpContext.GetFeature<ICanHasOwinEnvironment>().Environment);
|
||||
};
|
||||
};
|
||||
builder.Use(middleware2);
|
||||
var app = builder.Build();
|
||||
return env =>
|
||||
{
|
||||
return app.Invoke(
|
||||
new DefaultHttpContext(
|
||||
new FeatureCollection(
|
||||
new OwinHttpEnvironment(env))));
|
||||
};
|
||||
};
|
||||
return appBuilder.Use(middleware1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.AspNet.PipelineCore.Owin
|
||||
{
|
||||
public interface ICanHasOwinEnvironment
|
||||
{
|
||||
IDictionary<string, object> Environment { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="__ToolsVersion__" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>65c93d2b-cbd1-4e51-9312-10c1965a7241</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<ActiveTargetFramework>net45</ActiveTargetFramework>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'" Label="Configuration">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'" Label="Configuration">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Project.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppBuilderSupportExtensions.cs" />
|
||||
<Compile Include="ICanHasOwinEnvironment.cs" />
|
||||
<Compile Include="OwinConstants.cs" />
|
||||
<Compile Include="OwinHttpEnvironment.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
namespace Microsoft.AspNet.PipelineCore.Owin
|
||||
{
|
||||
internal static class OwinConstants
|
||||
{
|
||||
#region OWIN v1.0.0 - 3.2.1. Request Data
|
||||
|
||||
// http://owin.org/spec/owin-1.0.0.html
|
||||
|
||||
public const string RequestScheme = "owin.RequestScheme";
|
||||
public const string RequestMethod = "owin.RequestMethod";
|
||||
public const string RequestPathBase = "owin.RequestPathBase";
|
||||
public const string RequestPath = "owin.RequestPath";
|
||||
public const string RequestQueryString = "owin.RequestQueryString";
|
||||
public const string RequestProtocol = "owin.RequestProtocol";
|
||||
public const string RequestHeaders = "owin.RequestHeaders";
|
||||
public const string RequestBody = "owin.RequestBody";
|
||||
|
||||
#endregion
|
||||
|
||||
#region OWIN v1.0.0 - 3.2.2. Response Data
|
||||
|
||||
// http://owin.org/spec/owin-1.0.0.html
|
||||
|
||||
public const string ResponseStatusCode = "owin.ResponseStatusCode";
|
||||
public const string ResponseReasonPhrase = "owin.ResponseReasonPhrase";
|
||||
public const string ResponseProtocol = "owin.ResponseProtocol";
|
||||
public const string ResponseHeaders = "owin.ResponseHeaders";
|
||||
public const string ResponseBody = "owin.ResponseBody";
|
||||
|
||||
#endregion
|
||||
|
||||
#region OWIN v1.0.0 - 3.2.3. Other Data
|
||||
|
||||
// http://owin.org/spec/owin-1.0.0.html
|
||||
|
||||
public const string CallCancelled = "owin.CallCancelled";
|
||||
|
||||
public const string OwinVersion = "owin.Version";
|
||||
|
||||
#endregion
|
||||
|
||||
#region OWIN Keys for IAppBuilder.Properties
|
||||
|
||||
internal static class Builder
|
||||
{
|
||||
public const string AddSignatureConversion = "builder.AddSignatureConversion";
|
||||
public const string DefaultApp = "builder.DefaultApp";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OWIN Key Guidelines and Common Keys - 6. Common keys
|
||||
|
||||
// http://owin.org/spec/CommonKeys.html
|
||||
|
||||
internal static class CommonKeys
|
||||
{
|
||||
public const string ClientCertificate = "ssl.ClientCertificate";
|
||||
public const string LoadClientCertAsync = "ssl.LoadClientCertAsync";
|
||||
public const string RemoteIpAddress = "server.RemoteIpAddress";
|
||||
public const string RemotePort = "server.RemotePort";
|
||||
public const string LocalIpAddress = "server.LocalIpAddress";
|
||||
public const string LocalPort = "server.LocalPort";
|
||||
public const string IsLocal = "server.IsLocal";
|
||||
public const string TraceOutput = "host.TraceOutput";
|
||||
public const string Addresses = "host.Addresses";
|
||||
public const string AppName = "host.AppName";
|
||||
public const string Capabilities = "server.Capabilities";
|
||||
public const string OnSendingHeaders = "server.OnSendingHeaders";
|
||||
public const string OnAppDisposing = "host.OnAppDisposing";
|
||||
public const string Scheme = "scheme";
|
||||
public const string Host = "host";
|
||||
public const string Port = "port";
|
||||
public const string Path = "path";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SendFiles v0.3.0
|
||||
|
||||
// http://owin.org/extensions/owin-SendFile-Extension-v0.3.0.htm
|
||||
|
||||
internal static class SendFiles
|
||||
{
|
||||
// 3.1. Startup
|
||||
|
||||
public const string Version = "sendfile.Version";
|
||||
public const string Support = "sendfile.Support";
|
||||
public const string Concurrency = "sendfile.Concurrency";
|
||||
|
||||
// 3.2. Per Request
|
||||
|
||||
public const string SendAsync = "sendfile.SendAsync";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Opaque v0.3.0
|
||||
|
||||
// http://owin.org/extensions/owin-OpaqueStream-Extension-v0.3.0.htm
|
||||
|
||||
internal static class OpaqueConstants
|
||||
{
|
||||
// 3.1. Startup
|
||||
|
||||
public const string Version = "opaque.Version";
|
||||
|
||||
// 3.2. Per Request
|
||||
|
||||
public const string Upgrade = "opaque.Upgrade";
|
||||
|
||||
// 5. Consumption
|
||||
|
||||
public const string Stream = "opaque.Stream";
|
||||
// public const string Version = "opaque.Version"; // redundant, declared above
|
||||
public const string CallCancelled = "opaque.CallCancelled";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region WebSocket v0.4.0
|
||||
|
||||
// http://owin.org/extensions/owin-OpaqueStream-Extension-v0.3.0.htm
|
||||
|
||||
internal static class WebSocket
|
||||
{
|
||||
// 3.1. Startup
|
||||
|
||||
public const string Version = "websocket.Version";
|
||||
|
||||
// 3.2. Per Request
|
||||
|
||||
public const string Accept = "websocket.Accept";
|
||||
|
||||
// 4. Accept
|
||||
|
||||
public const string SubProtocol = "websocket.SubProtocol";
|
||||
|
||||
// 5. Consumption
|
||||
|
||||
public const string SendAsync = "websocket.SendAsync";
|
||||
public const string ReceiveAsync = "websocket.ReceiveAsync";
|
||||
public const string CloseAsync = "websocket.CloseAsync";
|
||||
// public const string Version = "websocket.Version"; // redundant, declared above
|
||||
public const string CallCancelled = "websocket.CallCancelled";
|
||||
public const string ClientCloseStatus = "websocket.ClientCloseStatus";
|
||||
public const string ClientCloseDescription = "websocket.ClientCloseDescription";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Security v0.1.0
|
||||
|
||||
// http://owin.org/extensions/owin-Security-Extension-v0.1.0.htm
|
||||
|
||||
internal static class Security
|
||||
{
|
||||
// 3.2. Per Request
|
||||
|
||||
public const string User = "server.User";
|
||||
|
||||
public const string Authenticate = "security.Authenticate";
|
||||
|
||||
// 3.3. Response
|
||||
|
||||
public const string SignIn = "security.SignIn";
|
||||
|
||||
public const string SignOut = "security.SignOut";
|
||||
|
||||
public const string Challenge = "security.Challenge";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -1,364 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
#if NET45
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
#endif
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.HttpFeature;
|
||||
using Microsoft.AspNet.FeatureModel;
|
||||
|
||||
namespace Microsoft.AspNet.PipelineCore.Owin
|
||||
{
|
||||
using SendFileFunc = Func<string, long, long?, CancellationToken, Task>;
|
||||
|
||||
public class OwinHttpEnvironment :
|
||||
IFeatureCollection,
|
||||
IHttpRequestInformation,
|
||||
IHttpResponseInformation,
|
||||
IHttpConnection,
|
||||
IHttpSendFile,
|
||||
IHttpTransportLayerSecurity,
|
||||
ICanHasOwinEnvironment
|
||||
{
|
||||
public IDictionary<string, object> Environment { get; set; }
|
||||
|
||||
public OwinHttpEnvironment(IDictionary<string, object> environment)
|
||||
{
|
||||
Environment = environment;
|
||||
}
|
||||
|
||||
T Prop<T>(string key)
|
||||
{
|
||||
object value;
|
||||
if (Environment.TryGetValue(key, out value) && value is T)
|
||||
{
|
||||
return (T)value;
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
void Prop(string key, object value)
|
||||
{
|
||||
Environment[key] = value;
|
||||
}
|
||||
|
||||
string IHttpRequestInformation.Protocol
|
||||
{
|
||||
get { return Prop<string>("owin.RequestProtocol"); }
|
||||
set { Prop("owin.RequestProtocol", value); }
|
||||
}
|
||||
|
||||
string IHttpRequestInformation.Scheme
|
||||
{
|
||||
get { return Prop<string>("owin.RequestScheme"); }
|
||||
set { Prop("owin.RequestScheme", value); }
|
||||
}
|
||||
|
||||
string IHttpRequestInformation.Method
|
||||
{
|
||||
get { return Prop<string>("owin.RequestMethod"); }
|
||||
set { Prop("owin.RequestMethod", value); }
|
||||
}
|
||||
|
||||
string IHttpRequestInformation.PathBase
|
||||
{
|
||||
get { return Prop<string>("owin.RequestPathBase"); }
|
||||
set { Prop("owin.RequestPathBase", value); }
|
||||
}
|
||||
|
||||
string IHttpRequestInformation.Path
|
||||
{
|
||||
get { return Prop<string>("owin.RequestPath"); }
|
||||
set { Prop("owin.RequestPath", value); }
|
||||
}
|
||||
|
||||
string IHttpRequestInformation.QueryString
|
||||
{
|
||||
get { return Prop<string>("owin.RequestQueryString"); }
|
||||
set { Prop("owin.RequestQueryString", value); }
|
||||
}
|
||||
|
||||
IDictionary<string, string[]> IHttpRequestInformation.Headers
|
||||
{
|
||||
get { return Prop<IDictionary<string, string[]>>("owin.RequestHeaders"); }
|
||||
set { Prop("owin.RequestHeaders", value); }
|
||||
}
|
||||
|
||||
Stream IHttpRequestInformation.Body
|
||||
{
|
||||
get { return Prop<Stream>("owin.RequestBody"); }
|
||||
set { Prop("owin.RequestBody", value); }
|
||||
}
|
||||
|
||||
int IHttpResponseInformation.StatusCode
|
||||
{
|
||||
get { return Prop<int>("owin.ResponseStatusCode"); }
|
||||
set { Prop("owin.ResponseStatusCode", value); }
|
||||
}
|
||||
|
||||
string IHttpResponseInformation.ReasonPhrase
|
||||
{
|
||||
get { return Prop<string>("owin.ResponseReasonPhrase"); }
|
||||
set { Prop("owin.ResponseReasonPhrase", value); }
|
||||
}
|
||||
|
||||
IDictionary<string, string[]> IHttpResponseInformation.Headers
|
||||
{
|
||||
get { return Prop<IDictionary<string, string[]>>("owin.ResponseHeaders"); }
|
||||
set { Prop("owin.ResponseHeaders", value); }
|
||||
}
|
||||
|
||||
Stream IHttpResponseInformation.Body
|
||||
{
|
||||
get { return Prop<Stream>("owin.ResponseBody"); }
|
||||
set { Prop("owin.ResponseBody", value); }
|
||||
}
|
||||
|
||||
void IHttpResponseInformation.OnSendingHeaders(Action<object> callback, object state)
|
||||
{
|
||||
// TODO:
|
||||
}
|
||||
#if NET45
|
||||
IPAddress IHttpConnection.RemoteIpAddress
|
||||
{
|
||||
get { return IPAddress.Parse(Prop<string>(OwinConstants.CommonKeys.RemoteIpAddress)); }
|
||||
set { Prop(OwinConstants.CommonKeys.RemoteIpAddress, value.ToString()); }
|
||||
}
|
||||
|
||||
IPAddress IHttpConnection.LocalIpAddress
|
||||
{
|
||||
get { return IPAddress.Parse(Prop<string>(OwinConstants.CommonKeys.LocalIpAddress)); }
|
||||
set { Prop(OwinConstants.CommonKeys.LocalIpAddress, value.ToString()); }
|
||||
}
|
||||
#endif
|
||||
int IHttpConnection.RemotePort
|
||||
{
|
||||
get { return int.Parse(Prop<string>(OwinConstants.CommonKeys.RemotePort)); }
|
||||
set { Prop(OwinConstants.CommonKeys.RemotePort, value.ToString(CultureInfo.InvariantCulture)); }
|
||||
}
|
||||
|
||||
int IHttpConnection.LocalPort
|
||||
{
|
||||
get { return int.Parse(Prop<string>(OwinConstants.CommonKeys.LocalPort)); }
|
||||
set { Prop(OwinConstants.CommonKeys.LocalPort, value.ToString(CultureInfo.InvariantCulture)); }
|
||||
}
|
||||
|
||||
bool IHttpConnection.IsLocal
|
||||
{
|
||||
get { return Prop<bool>(OwinConstants.CommonKeys.IsLocal); }
|
||||
set { Prop(OwinConstants.CommonKeys.LocalPort, value); }
|
||||
}
|
||||
|
||||
private bool SupportsSendFile
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj;
|
||||
return Environment.TryGetValue(OwinConstants.SendFiles.SendAsync, out obj) && obj != null;
|
||||
}
|
||||
}
|
||||
|
||||
Task IHttpSendFile.SendFileAsync(string path, long offset, long? length, CancellationToken cancellation)
|
||||
{
|
||||
object obj;
|
||||
if (Environment.TryGetValue(OwinConstants.SendFiles.SendAsync, out obj))
|
||||
{
|
||||
var func = (SendFileFunc)obj;
|
||||
return func(path, offset, length, cancellation);
|
||||
}
|
||||
throw new NotSupportedException(OwinConstants.SendFiles.SendAsync);
|
||||
}
|
||||
|
||||
private bool SupportsClientCerts
|
||||
{
|
||||
get
|
||||
{
|
||||
object obj;
|
||||
if (string.Equals("https", ((IHttpRequestInformation)this).Scheme, StringComparison.OrdinalIgnoreCase)
|
||||
&& (Environment.TryGetValue(OwinConstants.CommonKeys.LoadClientCertAsync, out obj)
|
||||
|| Environment.TryGetValue(OwinConstants.CommonKeys.ClientCertificate, out obj))
|
||||
&& obj != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#if NET45
|
||||
X509Certificate IHttpTransportLayerSecurity.ClientCertificate
|
||||
{
|
||||
get { return Prop<X509Certificate>(OwinConstants.CommonKeys.ClientCertificate); }
|
||||
set { Prop(OwinConstants.CommonKeys.ClientCertificate, value); }
|
||||
}
|
||||
#endif
|
||||
Task IHttpTransportLayerSecurity.LoadAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int Revision
|
||||
{
|
||||
get { return 0; } // Not modifiable
|
||||
}
|
||||
|
||||
public void Add(Type key, object value)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool ContainsKey(Type key)
|
||||
{
|
||||
// Does this type implement the requested interface?
|
||||
if (key.GetTypeInfo().IsAssignableFrom(this.GetType().GetTypeInfo()))
|
||||
{
|
||||
// Check for conditional features
|
||||
if (key == typeof(IHttpSendFile))
|
||||
{
|
||||
return SupportsSendFile;
|
||||
}
|
||||
else if (key == typeof(IHttpTransportLayerSecurity))
|
||||
{
|
||||
return SupportsClientCerts;
|
||||
}
|
||||
|
||||
// The rest of the features are always supported.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICollection<Type> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
var keys = new List<Type>()
|
||||
{
|
||||
typeof(IHttpRequestInformation),
|
||||
typeof(IHttpResponseInformation),
|
||||
typeof(IHttpConnection),
|
||||
typeof(ICanHasOwinEnvironment),
|
||||
};
|
||||
if (SupportsSendFile)
|
||||
{
|
||||
keys.Add(typeof(IHttpSendFile));
|
||||
}
|
||||
if (SupportsClientCerts)
|
||||
{
|
||||
keys.Add(typeof(IHttpTransportLayerSecurity));
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Remove(Type key)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool TryGetValue(Type key, out object value)
|
||||
{
|
||||
if (ContainsKey(key))
|
||||
{
|
||||
value = this;
|
||||
return true;
|
||||
}
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public ICollection<object> Values
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public object this[Type key]
|
||||
{
|
||||
get
|
||||
{
|
||||
object value;
|
||||
if (TryGetValue(key, out value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
throw new KeyNotFoundException(key.FullName);
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(KeyValuePair<Type, object> item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public bool Contains(KeyValuePair<Type, object> item)
|
||||
{
|
||||
object result;
|
||||
return TryGetValue(item.Key, out result) && result.Equals(item.Value);
|
||||
}
|
||||
|
||||
public void CopyTo(KeyValuePair<Type, object>[] array, int arrayIndex)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
throw new ArgumentNullException("array");
|
||||
}
|
||||
if (arrayIndex < 0 || arrayIndex > array.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("arrayIndex", arrayIndex, string.Empty);
|
||||
}
|
||||
var keys = Keys;
|
||||
if (keys.Count > array.Length - arrayIndex)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
foreach (var key in keys)
|
||||
{
|
||||
array[arrayIndex++] = new KeyValuePair<Type, object>(key, this[key]);
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Keys.Count; }
|
||||
}
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public bool Remove(KeyValuePair<Type, object> item)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<Type, object>> GetEnumerator()
|
||||
{
|
||||
return Keys.Select(type => new KeyValuePair<Type, object>(type, this[type])).GetEnumerator();
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"version": "0.1-alpha-*",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Abstractions": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.FeatureModel": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.PipelineCore": "0.1-alpha-*",
|
||||
"Microsoft.AspNet.HttpFeature" : ""
|
||||
},
|
||||
"configurations": {
|
||||
"net45": {
|
||||
"dependencies": {
|
||||
"Owin": "1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime.Remoting.Contexts;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Abstractions;
|
||||
using Owin;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.AppBuilderSupport.Tests
|
||||
{
|
||||
public class AppBuilderSupportTests
|
||||
{
|
||||
[Fact]
|
||||
public async Task BuildCanGoInsideAppBuilder()
|
||||
{
|
||||
var server = Microsoft.Owin.Testing.TestServer.Create(
|
||||
app => app.UseBuilder(HelloWorld));
|
||||
|
||||
var result = await server.CreateRequest("/hello").GetAsync();
|
||||
var body = await result.Content.ReadAsStringAsync();
|
||||
|
||||
Assert.Equal(result.StatusCode, HttpStatusCode.Accepted);
|
||||
Assert.Equal(body, "Hello world!");
|
||||
}
|
||||
|
||||
private void HelloWorld(IBuilder builder)
|
||||
{
|
||||
builder.Use(next => async context =>
|
||||
{
|
||||
await next(context);
|
||||
});
|
||||
builder.Run(async context =>
|
||||
{
|
||||
context.Response.StatusCode = 202;
|
||||
await context.Response.WriteAsync("Hello world!");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="__ToolsVersion__" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>83d44696-c790-4356-9187-79f89010ed4f</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'" Label="Configuration">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'" Label="Configuration">
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Project.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AppBuilderSupportTests.cs" />
|
||||
<Compile Include="OwinHttpEnvironmentTests.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.FeatureModel;
|
||||
using Microsoft.AspNet.HttpFeature;
|
||||
using Microsoft.AspNet.PipelineCore.Owin;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.AppBuilderSupport.Tests
|
||||
{
|
||||
public class OwinHttpEnvironmentTests
|
||||
{
|
||||
private T Get<T>(IFeatureCollection features)
|
||||
{
|
||||
object value;
|
||||
return features.TryGetValue(typeof(T), out value) ? (T)value : default(T);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OwinHttpEnvironmentCanBeCreated()
|
||||
{
|
||||
var env = new Dictionary<string, object>
|
||||
{
|
||||
{"owin.RequestMethod", "POST"}
|
||||
};
|
||||
var features = new FeatureObject( new OwinHttpEnvironment(env));
|
||||
|
||||
Assert.Equal(Get<IHttpRequestInformation>(features).Method, "POST");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImplementedInterfacesAreEnumerated()
|
||||
{
|
||||
var env = new Dictionary<string, object>
|
||||
{
|
||||
{"owin.RequestMethod", "POST"}
|
||||
};
|
||||
var features = new FeatureObject(new OwinHttpEnvironment(env));
|
||||
|
||||
var entries = features.ToArray();
|
||||
var keys = features.Keys.ToArray();
|
||||
var values = features.Values.ToArray();
|
||||
|
||||
Assert.Contains(typeof(IHttpRequestInformation), keys);
|
||||
Assert.Contains(typeof(IHttpResponseInformation), keys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
{
|
||||
"version": "0.1-alpha-*",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.AppBuilderSupport": "",
|
||||
"Microsoft.AspNet.HttpFeature": "",
|
||||
"Microsoft.AspNet.Abstractions": "",
|
||||
"Microsoft.AspNet.FeatureModel": "",
|
||||
"Xunit.KRunner": "0.1-alpha-*",
|
||||
"xunit.abstractions": "2.0.0-aspnet-*",
|
||||
"xunit.assert": "2.0.0-aspnet-*",
|
||||
"xunit.core": "2.0.0-aspnet-*",
|
||||
"xunit.execution": "2.0.0-aspnet-*"
|
||||
},
|
||||
"commands": {
|
||||
"test": "Xunit.KRunner"
|
||||
},
|
||||
"configurations": {
|
||||
"net45": {
|
||||
"dependencies": {
|
||||
"System.Runtime": "",
|
||||
"Owin": "1.0",
|
||||
"Microsoft.Owin": "2.1.0",
|
||||
"Microsoft.Owin.Hosting": "2.1.0",
|
||||
"Microsoft.Owin.Testing": "2.1.0",
|
||||
"Shouldly": "1.1.1.1",
|
||||
"System.Net.Http": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue