Reacting to new Hosting API
This commit is contained in:
parent
717b355bfd
commit
bd10d507f8
|
|
@ -1,3 +0,0 @@
|
|||
|
||||
Server = Microsoft.AspNet.Server.Kestrel
|
||||
Server.Urls = http://localhost:5001/
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Builder;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
|
||||
namespace LargeResponseApp
|
||||
{
|
||||
|
|
@ -34,5 +35,15 @@ namespace LargeResponseApp
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var application = new WebApplicationBuilder()
|
||||
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
|
||||
application.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"server": "Microsoft.AspNet.Server.Kestrel",
|
||||
"server.urls": "http://localhost:5001/"
|
||||
}
|
||||
|
|
@ -3,14 +3,14 @@
|
|||
"dependencies": {
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*"
|
||||
},
|
||||
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
"dnxcore50": { }
|
||||
},
|
||||
|
||||
"commands": {
|
||||
"run": "Microsoft.AspNet.Server.Kestrel",
|
||||
"web": "Microsoft.AspNet.Hosting"
|
||||
"web": "LargeResponseApp"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. 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.Linq;
|
||||
|
||||
namespace SampleApp
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var mergedArgs = new[] { "--server", "Microsoft.AspNet.Server.Kestrel" }.Concat(args).ToArray();
|
||||
Microsoft.AspNet.Hosting.Program.Main(mergedArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.IO;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Http.Features;
|
||||
using Microsoft.AspNet.Server.Kestrel;
|
||||
|
|
@ -61,5 +62,20 @@ namespace SampleApp
|
|||
await context.Response.WriteAsync("Hello world");
|
||||
});
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var application = new WebApplicationBuilder()
|
||||
.UseConfiguration(WebApplicationConfiguration.GetDefault(args))
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
|
||||
// The following section should be used to demo sockets
|
||||
//var addresses = application.GetAddresses();
|
||||
//addresses.Clear();
|
||||
//addresses.Add("http://unix:/tmp/kestrel-test.sock");
|
||||
|
||||
application.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"server": "Microsoft.AspNet.Server.Kestrel",
|
||||
"server.urls": "http://localhost:5000;https://localhost:5001"
|
||||
}
|
||||
|
|
@ -1,22 +1,23 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||
"version": "1.0.0-*",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.Kestrel.Https": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||
},
|
||||
"compilationOptions": {
|
||||
"emitEntryPoint": true
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
},
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"System.Console": "4.0.0-*"
|
||||
}
|
||||
}
|
||||
},
|
||||
"commands": {
|
||||
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000;https://localhost:5001",
|
||||
"kestrel": "Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000;https://localhost:5001",
|
||||
"run-socket": "Microsoft.AspNet.Server.Kestrel --server.urls http://unix:/tmp/kestrel-test.sock"
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"System.Console": "4.0.0-*"
|
||||
}
|
||||
}
|
||||
},
|
||||
"commands": {
|
||||
"web": "SampleApp"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" forwardWindowsAuthToken="false" startupTimeLimit="3600" />
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. 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.Linq;
|
||||
|
||||
namespace Microsoft.AspNet.Server.Kestrel
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var mergedArgs = new[] { "--server", "Microsoft.AspNet.Server.Kestrel" }.Concat(args).ToArray();
|
||||
Microsoft.AspNet.Hosting.Program.Main(mergedArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,11 +40,12 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests
|
|||
})
|
||||
.Build();
|
||||
|
||||
var hostBuilder = new WebHostBuilder(config);
|
||||
hostBuilder.UseServerFactory("Microsoft.AspNet.Server.Kestrel");
|
||||
hostBuilder.UseStartup(ConfigureEchoAddress);
|
||||
var applicationBuilder = new WebApplicationBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseServerFactory("Microsoft.AspNet.Server.Kestrel")
|
||||
.Configure(ConfigureEchoAddress);
|
||||
|
||||
using (var app = hostBuilder.Build().Start())
|
||||
using (var app = applicationBuilder.Build().Start())
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -79,9 +79,10 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests
|
|||
{ "server.urls", registerAddress }
|
||||
}).Build();
|
||||
|
||||
var builder = new WebHostBuilder(config)
|
||||
var builder = new WebApplicationBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseServerFactory("Microsoft.AspNet.Server.Kestrel")
|
||||
.UseStartup(app =>
|
||||
.Configure(app =>
|
||||
{
|
||||
app.Run(async context =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,31 +29,32 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests
|
|||
})
|
||||
.Build();
|
||||
|
||||
var hostBuilder = new WebHostBuilder(config);
|
||||
hostBuilder.UseServerFactory("Microsoft.AspNet.Server.Kestrel");
|
||||
hostBuilder.UseStartup(app =>
|
||||
{
|
||||
app.Run(async context =>
|
||||
var applicationBuilder = new WebApplicationBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseServerFactory("Microsoft.AspNet.Server.Kestrel")
|
||||
.Configure(app =>
|
||||
{
|
||||
// Read the full request body
|
||||
var total = 0;
|
||||
var bytes = new byte[1024];
|
||||
var count = await context.Request.Body.ReadAsync(bytes, 0, bytes.Length);
|
||||
while (count > 0)
|
||||
app.Run(async context =>
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
// Read the full request body
|
||||
var total = 0;
|
||||
var bytes = new byte[1024];
|
||||
var count = await context.Request.Body.ReadAsync(bytes, 0, bytes.Length);
|
||||
while (count > 0)
|
||||
{
|
||||
Assert.Equal(total % 256, bytes[i]);
|
||||
total++;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
Assert.Equal(total % 256, bytes[i]);
|
||||
total++;
|
||||
}
|
||||
count = await context.Request.Body.ReadAsync(bytes, 0, bytes.Length);
|
||||
}
|
||||
count = await context.Request.Body.ReadAsync(bytes, 0, bytes.Length);
|
||||
}
|
||||
|
||||
await context.Response.WriteAsync(total.ToString(CultureInfo.InvariantCulture));
|
||||
await context.Response.WriteAsync(total.ToString(CultureInfo.InvariantCulture));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
using (var app = hostBuilder.Build().Start())
|
||||
using (var app = applicationBuilder.Build().Start())
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
|
@ -97,9 +98,10 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests
|
|||
{ "server.urls", "http://localhost:8791" }
|
||||
}).Build();
|
||||
|
||||
var builder = new WebHostBuilder(config)
|
||||
var builder = new WebApplicationBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseServerFactory("Microsoft.AspNet.Server.Kestrel")
|
||||
.UseStartup(app =>
|
||||
.Configure(app =>
|
||||
{
|
||||
app.Run(async context =>
|
||||
{
|
||||
|
|
@ -126,9 +128,10 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests
|
|||
{ "server.urls", $"http://{registerAddress}:{port}" }
|
||||
}).Build();
|
||||
|
||||
var builder = new WebHostBuilder(config)
|
||||
var builder = new WebApplicationBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseServerFactory("Microsoft.AspNet.Server.Kestrel")
|
||||
.UseStartup(app =>
|
||||
.Configure(app =>
|
||||
{
|
||||
app.Run(async context =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -28,28 +28,29 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests
|
|||
})
|
||||
.Build();
|
||||
|
||||
var hostBuilder = new WebHostBuilder(config);
|
||||
hostBuilder.UseServerFactory("Microsoft.AspNet.Server.Kestrel");
|
||||
hostBuilder.UseStartup(app =>
|
||||
{
|
||||
app.Run(async context =>
|
||||
var applicationBuilder = new WebApplicationBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseServerFactory("Microsoft.AspNet.Server.Kestrel")
|
||||
.Configure(app =>
|
||||
{
|
||||
var bytes = new byte[1024];
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
app.Run(async context =>
|
||||
{
|
||||
bytes[i] = (byte)i;
|
||||
}
|
||||
var bytes = new byte[1024];
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
bytes[i] = (byte)i;
|
||||
}
|
||||
|
||||
context.Response.ContentLength = bytes.Length * 1024;
|
||||
context.Response.ContentLength = bytes.Length * 1024;
|
||||
|
||||
for (int i = 0; i < 1024; i++)
|
||||
{
|
||||
await context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
|
||||
}
|
||||
for (int i = 0; i < 1024; i++)
|
||||
{
|
||||
await context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
using (var app = hostBuilder.Build().Start())
|
||||
using (var app = applicationBuilder.Build().Start())
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
|
@ -85,9 +86,10 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests
|
|||
})
|
||||
.Build();
|
||||
|
||||
var hostBuilder = new WebHostBuilder(config)
|
||||
var hostBuilder = new WebApplicationBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseServerFactory("Microsoft.AspNet.Server.Kestrel")
|
||||
.UseStartup(app =>
|
||||
.Configure(app =>
|
||||
{
|
||||
app.Run(async context =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,19 +24,20 @@ namespace Microsoft.AspNet.Server.Kestrel.FunctionalTests
|
|||
})
|
||||
.Build();
|
||||
|
||||
var hostBuilder = new WebHostBuilder(config);
|
||||
hostBuilder.UseServerFactory("Microsoft.AspNet.Server.Kestrel");
|
||||
hostBuilder.UseStartup(app =>
|
||||
{
|
||||
var serverInfo = app.ServerFeatures.Get<IKestrelServerInformation>();
|
||||
serverInfo.ThreadCount = threadCount;
|
||||
app.Run(context =>
|
||||
var applicationBuilder = new WebApplicationBuilder()
|
||||
.UseConfiguration(config)
|
||||
.UseServerFactory("Microsoft.AspNet.Server.Kestrel")
|
||||
.Configure(app =>
|
||||
{
|
||||
return context.Response.WriteAsync("Hello World");
|
||||
});
|
||||
});
|
||||
var serverInfo = app.ServerFeatures.Get<IKestrelServerInformation>();
|
||||
serverInfo.ThreadCount = threadCount;
|
||||
app.Run(context =>
|
||||
{
|
||||
return context.Response.WriteAsync("Hello World");
|
||||
});
|
||||
});
|
||||
|
||||
using (var app = hostBuilder.Build().Start())
|
||||
using (var app = applicationBuilder.Build().Start())
|
||||
{
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue