Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit f717867

Browse files
updating kestrel pure owin to netstandard 2
1 parent fe66014 commit f717867

5 files changed

Lines changed: 23 additions & 21 deletions

File tree

src/KestrelPureOwin/KestrelOwinServer.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
using System.Linq;
44
using System.Threading;
55
using System.Threading.Tasks;
6-
using Microsoft.AspNetCore.Hosting.Internal;
76
using Microsoft.AspNetCore.Hosting.Server.Features;
8-
using Microsoft.AspNetCore.Server.Kestrel;
97
using Microsoft.Extensions.Logging;
108
using Microsoft.Extensions.Options;
119
using static KestrelPureOwin.Constants;
1210

1311
namespace KestrelPureOwin
1412
{
13+
using Microsoft.AspNetCore.Hosting.Internal;
14+
using Microsoft.AspNetCore.Server.Kestrel.Core;
15+
using Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv;
1516
using AppFunc = Func<IDictionary<string, object>, Task>;
1617

1718
using MidFunc = Func<
@@ -49,37 +50,34 @@ public KestrelOwinServer(KestrelServerOptions options)
4950

5051
var wrappedOptions = Options.Create(options);
5152

52-
var lifetime = new ApplicationLifetime();
53-
5453
var loggerFactory = new LoggerFactory();
5554

56-
Server = new KestrelServer(wrappedOptions, lifetime, loggerFactory);
55+
var transport = new LibuvTransportFactory(
56+
Options.Create(new LibuvTransportOptions()),
57+
new ApplicationLifetime(loggerFactory.CreateLogger<ApplicationLifetime>()),
58+
loggerFactory);
59+
60+
Server = new KestrelServer(wrappedOptions, transport, loggerFactory);
5761
}
5862

5963
private static KestrelServerOptions GetOptions(IDictionary<string, object> properties)
6064
=> new KestrelServerOptions();
6165

6266
public KestrelServer Server { get; }
6367

64-
public void Run(string url, Action<BuildFunc> configure)
68+
public Task Run(string url, Action<BuildFunc> configure, CancellationToken cancellationToken)
6569
{
66-
var done = new ManualResetEventSlim(false);
67-
6870
Console.CancelKeyPress += (s, e) =>
6971
{
7072
Console.WriteLine("Application is shutting down...");
7173

72-
done.Set();
73-
7474
e.Cancel = true;
7575
};
7676

77-
Start(url, configure);
78-
79-
done.Wait();
77+
return Start(url, configure, cancellationToken);
8078
}
8179

82-
public void Start(string url, Action<BuildFunc> configure)
80+
public Task Start(string url, Action<BuildFunc> configure, CancellationToken cancellationToken)
8381
{
8482
var application = ConfigureApplication(configure);
8583

@@ -97,7 +95,7 @@ public void Start(string url, Action<BuildFunc> configure)
9795
Console.WriteLine($"Now listening on: {address}");
9896
}
9997

100-
Server.Start(application);
98+
return Server.StartAsync(application, cancellationToken);
10199
}
102100

103101
public void Dispose() => Server.Dispose();
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard1.3</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55
<AssemblyName>KestrelPureOwin</AssemblyName>
66
<PackageId>KestrelPureOwin</PackageId>
77
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
@@ -10,8 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
14-
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />
15-
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="1.1.1" />
13+
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.0" />
14+
<PackageReference Include="Microsoft.Extensions.ObjectPool" Version="2.0.0" />
1615
</ItemGroup>
1716
</Project>

src/KestrelPureOwin/ReverseOwinHeaderDictionary.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ StringValues IHeaderDictionary.this[string key]
3333
set { Inner[key] = value; }
3434
}
3535

36+
public long? ContentLength { get; set; }
37+
3638
StringValues IDictionary<string, StringValues>.this[string key]
3739
{
3840
get { return Inner[key]; }

src/SqlStreamStore.HAL.DevServer/Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
{
33
using System;
44
using System.Linq;
5+
using System.Threading;
56
using System.Threading.Tasks;
67
using KestrelPureOwin;
78
using Microsoft.AspNetCore.Server.Kestrel;
9+
using Microsoft.AspNetCore.Server.Kestrel.Core;
810
using SqlStreamStore.Streams;
911
using BuildFunc = System.Action<
1012
System.Func<
@@ -19,7 +21,7 @@ internal static class Program
1921
{
2022
private static readonly Random s_random = new Random();
2123

22-
public static int Main(string[] args)
24+
public static async Task<int> Main(string[] args)
2325
{
2426
var options = new KestrelServerOptions
2527
{
@@ -29,7 +31,7 @@ public static int Main(string[] args)
2931
using(var server = new KestrelOwinServer(options))
3032
using(var streamStore = new InMemoryStreamStore())
3133
{
32-
server.Start("http://localhost:80", Configure(streamStore));
34+
await server.Start("http://localhost:80", Configure(streamStore), CancellationToken.None);
3335

3436
DisplayMenu(streamStore);
3537
}

src/SqlStreamStore.HAL.DevServer/SqlStreamStore.HAL.DevServer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
44
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<LangVersion>7.1</LangVersion>
56
</PropertyGroup>
67
<ItemGroup>
78
<ProjectReference Include="..\KestrelPureOwin\KestrelPureOwin.csproj" />

0 commit comments

Comments
 (0)