diff --git a/WebListener.sln b/WebListener.sln
index 5623786..21d618b 100644
--- a/WebListener.sln
+++ b/WebListener.sln
@@ -10,17 +10,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{E183C826-1
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{3A1E31E3-2794-4CA3-B8E2-253E96BDE514}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Net.Http.Server", "src\Microsoft.Net.Http.Server\Microsoft.Net.Http.Server.xproj", "{3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}"
-EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "HelloWorld", "samples\HelloWorld\HelloWorld.xproj", "{6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}"
-EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "SelfHostServer", "samples\SelfHostServer\SelfHostServer.xproj", "{1236F93A-AC5C-4A77-9477-C88F040151CA}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Server.WebListener.FunctionalTests", "test\Microsoft.AspNetCore.Server.WebListener.FunctionalTests\Microsoft.AspNetCore.Server.WebListener.FunctionalTests.xproj", "{4492FF4C-9032-411D-853F-46B01755E504}"
-EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Server.WebListener", "src\Microsoft.AspNetCore.Server.WebListener\Microsoft.AspNetCore.Server.WebListener.xproj", "{B9F45F9D-D206-47F0-8E5F-54CE2F0BDF92}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Server.HttpSys.FunctionalTests", "test\Microsoft.AspNetCore.Server.HttpSys.FunctionalTests\Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.xproj", "{4492FF4C-9032-411D-853F-46B01755E504}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Net.Http.Server.FunctionalTests", "test\Microsoft.Net.Http.Server.FunctionalTests\Microsoft.Net.Http.Server.FunctionalTests.xproj", "{DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Server.HttpSys", "src\Microsoft.AspNetCore.Server.HttpSys\Microsoft.AspNetCore.Server.HttpSys.xproj", "{B9F45F9D-D206-47F0-8E5F-54CE2F0BDF92}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5E9B546C-17AC-4BDF-BCB3-5955D4755ED8}"
ProjectSection(SolutionItems) = preProject
@@ -29,7 +23,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "HotAddSample", "samples\HotAddSample\HotAddSample.xproj", "{8BFA392A-8B67-4454-916B-67C545EDFAEF}"
EndProject
-Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Net.Http.Server.Tests", "test\Microsoft.Net.Http.Server.Tests\Microsoft.Net.Http.Server.Tests.xproj", "{E837249E-E666-4DF2-AFC3-7A4D70234F9F}"
+Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Server.HttpSys.Tests", "test\Microsoft.AspNetCore.Server.HttpSys.Tests\Microsoft.AspNetCore.Server.HttpSys.Tests.xproj", "{E837249E-E666-4DF2-AFC3-7A4D70234F9F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -51,26 +45,6 @@ Global
{8B828433-B333-4C19-96AE-00BFFF9D8841}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8B828433-B333-4C19-96AE-00BFFF9D8841}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8B828433-B333-4C19-96AE-00BFFF9D8841}.Release|x86.ActiveCfg = Release|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Debug|x86.ActiveCfg = Debug|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Release|Any CPU.Build.0 = Release|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1}.Release|x86.ActiveCfg = Release|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Debug|x86.ActiveCfg = Debug|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Release|Any CPU.Build.0 = Release|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4}.Release|x86.ActiveCfg = Release|Any CPU
{1236F93A-AC5C-4A77-9477-C88F040151CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1236F93A-AC5C-4A77-9477-C88F040151CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1236F93A-AC5C-4A77-9477-C88F040151CA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -101,16 +75,6 @@ Global
{B9F45F9D-D206-47F0-8E5F-54CE2F0BDF92}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{B9F45F9D-D206-47F0-8E5F-54CE2F0BDF92}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{B9F45F9D-D206-47F0-8E5F-54CE2F0BDF92}.Release|x86.ActiveCfg = Release|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Debug|x86.ActiveCfg = Debug|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Release|Any CPU.Build.0 = Release|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Release|Mixed Platforms.Build.0 = Release|Any CPU
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1}.Release|x86.ActiveCfg = Release|Any CPU
{8BFA392A-8B67-4454-916B-67C545EDFAEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BFA392A-8B67-4454-916B-67C545EDFAEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BFA392A-8B67-4454-916B-67C545EDFAEF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -141,12 +105,9 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8B828433-B333-4C19-96AE-00BFFF9D8841} = {3A1E31E3-2794-4CA3-B8E2-253E96BDE514}
- {3F5212AA-E287-49DD-8CEC-44BF0A2AC9A1} = {99D5E5F3-88F5-4CCF-8D8C-717C8925DF09}
- {6DAF3E6B-8E1B-4E6E-B9FE-7B1E5FDB7DB4} = {3A1E31E3-2794-4CA3-B8E2-253E96BDE514}
{1236F93A-AC5C-4A77-9477-C88F040151CA} = {3A1E31E3-2794-4CA3-B8E2-253E96BDE514}
{4492FF4C-9032-411D-853F-46B01755E504} = {E183C826-1360-4DFF-9994-F33CED5C8525}
{B9F45F9D-D206-47F0-8E5F-54CE2F0BDF92} = {99D5E5F3-88F5-4CCF-8D8C-717C8925DF09}
- {DCB6E0B1-223D-44E6-8696-4767E5B6E6A1} = {E183C826-1360-4DFF-9994-F33CED5C8525}
{8BFA392A-8B67-4454-916B-67C545EDFAEF} = {3A1E31E3-2794-4CA3-B8E2-253E96BDE514}
{E837249E-E666-4DF2-AFC3-7A4D70234F9F} = {E183C826-1360-4DFF-9994-F33CED5C8525}
EndGlobalSection
diff --git a/samples/HelloWorld/HelloWorld.xproj b/samples/HelloWorld/HelloWorld.xproj
deleted file mode 100644
index 4506551..0000000
--- a/samples/HelloWorld/HelloWorld.xproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- 14.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
-
-
-
- 6daf3e6b-8e1b-4e6e-b9fe-7b1e5fdb7db4
- .\obj
- .\bin\
-
-
- 2.0
-
-
-
\ No newline at end of file
diff --git a/samples/HelloWorld/Program.cs b/samples/HelloWorld/Program.cs
deleted file mode 100644
index dac0e30..0000000
--- a/samples/HelloWorld/Program.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using System;
-using System.Net.WebSockets;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.Net.Http.Server;
-
-namespace HelloWorld
-{
- public class Program
- {
- public static void Main(string[] args)
- {
- Run(args).Wait();
- }
-
- public static async Task Run(string[] args)
- {
- var settings = new WebListenerSettings();
- settings.UrlPrefixes.Add("http://localhost:8080");
-
- using (WebListener listener = new WebListener(settings))
- {
- listener.Start();
-
- Console.WriteLine("Running...");
- while (true)
- {
- RequestContext context = await listener.AcceptAsync();
- Console.WriteLine("Accepted");
-
- // Context:
- // context.User;
- // context.DisconnectToken
- // context.Dispose()
- // context.Abort();
-
- // Request
- // context.Request.ProtocolVersion
- // context.Request.Headers
- // context.Request.Method
- // context.Request.Body
- // Content-Length - long?
- // Content-Type - string
- // IsSecureConnection
- // HasEntityBody
-
- // TODO: Request fields
- // Content-Encoding - Encoding
- // Host
- // Client certs - GetCertAsync, CertErrors
- // Cookies
- // KeepAlive
- // QueryString (parsed)
- // RequestTraceIdentifier
- // RawUrl
- // URI
- // IsWebSocketRequest
- // LocalEndpoint vs LocalIP & LocalPort
- // RemoteEndpoint vs RemoteIP & RemotePort
- // AcceptTypes string[]
- // ServiceName
- // TransportContext
-
- // Response
- byte[] bytes = Encoding.ASCII.GetBytes("Hello World: " + DateTime.Now);
-
- if (context.IsWebSocketRequest)
- {
- Console.WriteLine("WebSocket");
- WebSocket webSocket = await context.AcceptWebSocketAsync();
- await webSocket.SendAsync(new ArraySegment(bytes, 0, bytes.Length), WebSocketMessageType.Text, true, CancellationToken.None);
- await webSocket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Goodbye", CancellationToken.None);
- webSocket.Dispose();
- }
- else
- {
- Console.WriteLine("Hello World");
- context.Response.ContentLength = bytes.Length;
- context.Response.ContentType = "text/plain";
-
- context.Response.Body.Write(bytes, 0, bytes.Length);
- context.Dispose();
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/samples/HelloWorld/Properties/launchSettings.json b/samples/HelloWorld/Properties/launchSettings.json
deleted file mode 100644
index f96a6f4..0000000
--- a/samples/HelloWorld/Properties/launchSettings.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "profiles": {
- "HelloWorld": {
- "commandName": "Project",
- "launchBrowser": true,
- "launchUrl": "http://localhost:8080"
- }
- }
-}
\ No newline at end of file
diff --git a/samples/HelloWorld/project.json b/samples/HelloWorld/project.json
deleted file mode 100644
index 2d1231f..0000000
--- a/samples/HelloWorld/project.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "buildOptions": {
- "emitEntryPoint": true
- },
- "dependencies": {
- "Microsoft.Net.Http.Server": "1.2.0-*"
- },
- "commands": {
- "sample": "HelloWorld"
- },
- "frameworks": {
- "net451": {},
- "netcoreapp1.1": {
- "dependencies": {
- "Microsoft.NETCore.App": {
- "version": "1.2.0-*",
- "type": "platform"
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/samples/HotAddSample/Startup.cs b/samples/HotAddSample/Startup.cs
index a6cf016..f0ede45 100644
--- a/samples/HotAddSample/Startup.cs
+++ b/samples/HotAddSample/Startup.cs
@@ -2,10 +2,9 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Server.WebListener;
+using Microsoft.AspNetCore.Server.HttpSys;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Microsoft.Net.Http.Server;
namespace HotAddSample
{
@@ -16,19 +15,19 @@ public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
- services.Configure(options =>
+ services.Configure(options =>
{
- ListenerSettings = options.ListenerSettings;
+ ServerOptions = options;
});
}
- public WebListenerSettings ListenerSettings { get; set; }
+ public HttpSysOptions ServerOptions { get; set; }
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
{
loggerfactory.AddConsole(LogLevel.Information);
- var addresses = ListenerSettings.UrlPrefixes;
+ var addresses = ServerOptions.UrlPrefixes;
addresses.Add("http://localhost:12346/pathBase/");
app.Use(async (context, next) =>
@@ -103,7 +102,7 @@ public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseStartup()
- .UseWebListener()
+ .UseHttpSys()
.Build();
host.Run();
diff --git a/samples/HotAddSample/project.json b/samples/HotAddSample/project.json
index f67b728..e351732 100644
--- a/samples/HotAddSample/project.json
+++ b/samples/HotAddSample/project.json
@@ -1,6 +1,6 @@
{
"dependencies": {
- "Microsoft.AspNetCore.Server.WebListener": "1.2.0-*",
+ "Microsoft.AspNetCore.Server.HttpSys": "1.2.0-*",
"Microsoft.Extensions.Logging.Console": "1.2.0-*"
},
"buildOptions": {
diff --git a/samples/SelfHostServer/Startup.cs b/samples/SelfHostServer/Startup.cs
index c6a9fec..f327d5b 100644
--- a/samples/SelfHostServer/Startup.cs
+++ b/samples/SelfHostServer/Startup.cs
@@ -5,10 +5,9 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Server.WebListener;
+using Microsoft.AspNetCore.Server.HttpSys;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Microsoft.Net.Http.Server;
namespace SelfHostServer
{
@@ -17,10 +16,10 @@ public class Startup
public void ConfigureServices(IServiceCollection services)
{
// Server options can be configured here instead of in Main.
- services.Configure(options =>
+ services.Configure(options =>
{
- options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.None;
- options.ListenerSettings.Authentication.AllowAnonymous = true;
+ options.Authentication.Schemes = AuthenticationSchemes.None;
+ options.Authentication.AllowAnonymous = true;
});
}
@@ -50,10 +49,10 @@ public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseStartup()
- .UseWebListener(options =>
+ .UseHttpSys(options =>
{
- options.ListenerSettings.Authentication.Schemes = AuthenticationSchemes.None;
- options.ListenerSettings.Authentication.AllowAnonymous = true;
+ options.Authentication.Schemes = AuthenticationSchemes.None;
+ options.Authentication.AllowAnonymous = true;
})
.Build();
diff --git a/samples/SelfHostServer/project.json b/samples/SelfHostServer/project.json
index 4714c23..756b800 100644
--- a/samples/SelfHostServer/project.json
+++ b/samples/SelfHostServer/project.json
@@ -1,6 +1,6 @@
{
"dependencies": {
- "Microsoft.AspNetCore.Server.WebListener": "1.2.0-*",
+ "Microsoft.AspNetCore.Server.HttpSys": "1.2.0-*",
"Microsoft.Extensions.Logging.Console": "1.2.0-*"
},
"buildOptions": {
diff --git a/src/Microsoft.Net.Http.Server/AsyncAcceptContext.cs b/src/Microsoft.AspNetCore.Server.HttpSys/AsyncAcceptContext.cs
similarity index 94%
rename from src/Microsoft.Net.Http.Server/AsyncAcceptContext.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/AsyncAcceptContext.cs
index 608e46d..3057e13 100644
--- a/src/Microsoft.Net.Http.Server/AsyncAcceptContext.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/AsyncAcceptContext.cs
@@ -7,17 +7,17 @@
using System.Threading;
using System.Threading.Tasks;
-namespace Microsoft.Net.Http.Server
+namespace Microsoft.AspNetCore.Server.HttpSys
{
internal unsafe class AsyncAcceptContext : IAsyncResult, IDisposable
{
internal static readonly IOCompletionCallback IOCallback = new IOCompletionCallback(IOWaitCallback);
private TaskCompletionSource _tcs;
- private WebListener _server;
+ private HttpSysListener _server;
private NativeRequestContext _nativeRequestContext;
- internal AsyncAcceptContext(WebListener server)
+ internal AsyncAcceptContext(HttpSysListener server)
{
_server = server;
_tcs = new TaskCompletionSource();
@@ -40,7 +40,7 @@ private TaskCompletionSource Tcs
}
}
- internal WebListener Server
+ internal HttpSysListener Server
{
get
{
@@ -58,12 +58,12 @@ private static void IOCompleted(AsyncAcceptContext asyncResult, uint errorCode,
if (errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS &&
errorCode != UnsafeNclNativeMethods.ErrorCodes.ERROR_MORE_DATA)
{
- asyncResult.Tcs.TrySetException(new WebListenerException((int)errorCode));
+ asyncResult.Tcs.TrySetException(new HttpSysException((int)errorCode));
complete = true;
}
else
{
- WebListener server = asyncResult.Server;
+ HttpSysListener server = asyncResult.Server;
if (errorCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
{
// at this point we have received an unmanaged HTTP_REQUEST and memoryBlob
@@ -106,7 +106,7 @@ private static void IOCompleted(AsyncAcceptContext asyncResult, uint errorCode,
{
// someother bad error, possible(?) return values are:
// ERROR_INVALID_HANDLE, ERROR_INSUFFICIENT_BUFFER, ERROR_OPERATION_ABORTED
- asyncResult.Tcs.TrySetException(new WebListenerException((int)statusCode));
+ asyncResult.Tcs.TrySetException(new HttpSysException((int)statusCode));
complete = true;
}
}
@@ -169,7 +169,7 @@ internal uint QueueBeginGetContext()
retry = true;
}
else if (statusCode == UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS
- && WebListener.SkipIOCPCallbackOnSuccess)
+ && HttpSysListener.SkipIOCPCallbackOnSuccess)
{
// IO operation completed synchronously - callback won't be called to signal completion.
IOCompleted(this, statusCode, bytesTransferred);
diff --git a/src/Microsoft.AspNetCore.Server.WebListener/AuthenticationHandler.cs b/src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationHandler.cs
similarity index 98%
rename from src/Microsoft.AspNetCore.Server.WebListener/AuthenticationHandler.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationHandler.cs
index d556fca..81c030e 100644
--- a/src/Microsoft.AspNetCore.Server.WebListener/AuthenticationHandler.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationHandler.cs
@@ -7,9 +7,8 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features.Authentication;
using Microsoft.Extensions.Internal;
-using Microsoft.Net.Http.Server;
-namespace Microsoft.AspNetCore.Server.WebListener
+namespace Microsoft.AspNetCore.Server.HttpSys
{
internal class AuthenticationHandler : IAuthenticationHandler
{
diff --git a/src/Microsoft.Net.Http.Server/AuthenticationManager.cs b/src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationManager.cs
similarity index 99%
rename from src/Microsoft.Net.Http.Server/AuthenticationManager.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationManager.cs
index 31b1b9b..e4b728d 100644
--- a/src/Microsoft.Net.Http.Server/AuthenticationManager.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationManager.cs
@@ -10,7 +10,7 @@
using System.Security.Principal;
using Microsoft.Extensions.Primitives;
-namespace Microsoft.Net.Http.Server
+namespace Microsoft.AspNetCore.Server.HttpSys
{
// See the native HTTP_SERVER_AUTHENTICATION_INFO structure documentation for additional information.
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa364638(v=vs.85).aspx
diff --git a/src/Microsoft.Net.Http.Server/AuthenticationSchemes.cs b/src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationSchemes.cs
similarity index 91%
rename from src/Microsoft.Net.Http.Server/AuthenticationSchemes.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationSchemes.cs
index a531724..3d82bda 100644
--- a/src/Microsoft.Net.Http.Server/AuthenticationSchemes.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/AuthenticationSchemes.cs
@@ -3,7 +3,7 @@
using System;
-namespace Microsoft.Net.Http.Server
+namespace Microsoft.AspNetCore.Server.HttpSys
{
// REVIEW: this appears to be very similar to System.Net.AuthenticationSchemes
[Flags]
diff --git a/src/Microsoft.Net.Http.Server/Constants.cs b/src/Microsoft.AspNetCore.Server.HttpSys/Constants.cs
similarity index 93%
rename from src/Microsoft.Net.Http.Server/Constants.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/Constants.cs
index 866b87d..83a8067 100644
--- a/src/Microsoft.Net.Http.Server/Constants.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/Constants.cs
@@ -3,7 +3,7 @@
using System;
-namespace Microsoft.Net.Http.Server
+namespace Microsoft.AspNetCore.Server.HttpSys
{
internal static class Constants
{
diff --git a/src/Microsoft.AspNetCore.Server.WebListener/FeatureContext.cs b/src/Microsoft.AspNetCore.Server.HttpSys/FeatureContext.cs
similarity index 99%
rename from src/Microsoft.AspNetCore.Server.WebListener/FeatureContext.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/FeatureContext.cs
index d2a0bd5..867e1e5 100644
--- a/src/Microsoft.AspNetCore.Server.WebListener/FeatureContext.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/FeatureContext.cs
@@ -16,9 +16,8 @@
using Microsoft.AspNetCore.Http.Features.Authentication;
using Microsoft.Extensions.Internal;
using Microsoft.Net.Http.Headers;
-using Microsoft.Net.Http.Server;
-namespace Microsoft.AspNetCore.Server.WebListener
+namespace Microsoft.AspNetCore.Server.HttpSys
{
internal class FeatureContext :
IHttpRequestFeature,
diff --git a/src/Microsoft.AspNetCore.Server.WebListener/HeaderDictionary.cs b/src/Microsoft.AspNetCore.Server.HttpSys/HeaderDictionary.cs
similarity index 99%
rename from src/Microsoft.AspNetCore.Server.WebListener/HeaderDictionary.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/HeaderDictionary.cs
index 6676fd8..fdc00ee 100644
--- a/src/Microsoft.AspNetCore.Server.WebListener/HeaderDictionary.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/HeaderDictionary.cs
@@ -7,7 +7,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
-namespace Microsoft.AspNetCore.Server.WebListener
+namespace Microsoft.AspNetCore.Server.HttpSys
{
///
/// Represents a wrapper for RequestHeaders and ResponseHeaders.
diff --git a/src/Microsoft.Net.Http.Server/Helpers.cs b/src/Microsoft.AspNetCore.Server.HttpSys/Helpers.cs
similarity index 98%
rename from src/Microsoft.Net.Http.Server/Helpers.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/Helpers.cs
index fb79443..9fee1c1 100644
--- a/src/Microsoft.Net.Http.Server/Helpers.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/Helpers.cs
@@ -7,7 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
-namespace Microsoft.Net.Http.Server
+namespace Microsoft.AspNetCore.Server.HttpSys
{
internal static class Helpers
{
diff --git a/src/Microsoft.Net.Http.Server/WebListenerException.cs b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysException.cs
similarity index 78%
rename from src/Microsoft.Net.Http.Server/WebListenerException.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/HttpSysException.cs
index 3b3b91d..7d9b6aa 100644
--- a/src/Microsoft.Net.Http.Server/WebListenerException.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysException.cs
@@ -6,22 +6,22 @@
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
-namespace Microsoft.Net.Http.Server
+namespace Microsoft.AspNetCore.Server.HttpSys
{
[SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable")]
- public class WebListenerException : Win32Exception
+ public class HttpSysException : Win32Exception
{
- internal WebListenerException()
+ internal HttpSysException()
: base(Marshal.GetLastWin32Error())
{
}
- internal WebListenerException(int errorCode)
+ internal HttpSysException(int errorCode)
: base(errorCode)
{
}
- internal WebListenerException(int errorCode, string message)
+ internal HttpSysException(int errorCode, string message)
: base(errorCode, message)
{
}
diff --git a/src/Microsoft.Net.Http.Server/WebListener.cs b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysListener.cs
similarity index 90%
rename from src/Microsoft.Net.Http.Server/WebListener.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/HttpSysListener.cs
index 903103d..a42c1f9 100644
--- a/src/Microsoft.Net.Http.Server/WebListener.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysListener.cs
@@ -6,14 +6,15 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
-namespace Microsoft.Net.Http.Server
+namespace Microsoft.AspNetCore.Server.HttpSys
{
///
/// An HTTP server wrapping the Http.Sys APIs that accepts requests.
///
- public sealed class WebListener : IDisposable
+ internal class HttpSysListener : IDisposable
{
// Win8# 559317 fixed a bug in Http.sys's HttpReceiveClientCertificate method.
// Without this fix IOCP callbacks were not being called although ERROR_IO_PENDING was
@@ -39,16 +40,15 @@ public sealed class WebListener : IDisposable
private object _internalLock;
- public WebListener()
- : this(new WebListenerSettings())
+ public HttpSysListener(HttpSysOptions options, ILoggerFactory loggerFactory)
{
- }
-
- public WebListener(WebListenerSettings settings)
- {
- if (settings == null)
+ if (options == null)
+ {
+ throw new ArgumentNullException(nameof(options));
+ }
+ if (loggerFactory == null)
{
- throw new ArgumentNullException(nameof(settings));
+ throw new ArgumentNullException(nameof(loggerFactory));
}
if (!HttpApi.Supported)
@@ -58,7 +58,9 @@ public WebListener(WebListenerSettings settings)
Debug.Assert(HttpApi.ApiVersion == HttpApi.HTTP_API_VERSION.Version20, "Invalid Http api version");
- Settings = settings;
+ Options = options;
+
+ Logger = LogHelper.CreateLogger(loggerFactory, typeof(HttpSysListener));
_state = State.Stopped;
_internalLock = new object();
@@ -98,10 +100,7 @@ internal enum State
Disposed,
}
- internal ILogger Logger
- {
- get { return Settings.Logger; }
- }
+ internal ILogger Logger { get; private set; }
internal UrlGroup UrlGroup
{
@@ -118,7 +117,7 @@ internal DisconnectListener DisconnectListener
get { return _disconnectListener; }
}
- public WebListenerSettings Settings { get; }
+ public HttpSysOptions Options { get; }
public bool IsListening
{
@@ -147,18 +146,18 @@ public void Start()
return;
}
- Settings.Authentication.SetUrlGroupSecurity(UrlGroup);
- Settings.Timeouts.SetUrlGroupTimeouts(UrlGroup);
- Settings.SetRequestQueueLimit(RequestQueue);
+ Options.Authentication.SetUrlGroupSecurity(UrlGroup);
+ Options.Timeouts.SetUrlGroupTimeouts(UrlGroup);
+ Options.SetRequestQueueLimit(RequestQueue);
_requestQueue.AttachToUrlGroup();
// All resources are set up correctly. Now add all prefixes.
try
{
- Settings.UrlPrefixes.RegisterAllPrefixes(UrlGroup);
+ Options.UrlPrefixes.RegisterAllPrefixes(UrlGroup);
}
- catch (WebListenerException)
+ catch (HttpSysException)
{
// If an error occurred while adding prefixes, free all resources allocated by previous steps.
_requestQueue.DetachFromUrlGroup();
@@ -190,7 +189,7 @@ private void Stop()
return;
}
- Settings.UrlPrefixes.UnregisterAllPrefixes();
+ Options.UrlPrefixes.UnregisterAllPrefixes();
_state = State.Stopped;
@@ -284,7 +283,7 @@ public Task AcceptAsync()
// some other bad error, possible(?) return values are:
// ERROR_INVALID_HANDLE, ERROR_INSUFFICIENT_BUFFER, ERROR_OPERATION_ABORTED
asyncResult.Dispose();
- throw new WebListenerException((int)statusCode);
+ throw new HttpSysException((int)statusCode);
}
}
catch (Exception exception)
@@ -301,7 +300,7 @@ internal unsafe bool ValidateRequest(NativeRequestContext requestMemory)
// Block potential DOS attacks
if (requestMemory.UnknownHeaderCount > UnknownHeaderLimit)
{
- SendError(requestMemory.RequestId, HttpStatusCode.BadRequest, authChallenges: null);
+ SendError(requestMemory.RequestId, StatusCodes.Status400BadRequest, authChallenges: null);
return false;
}
return true;
@@ -309,16 +308,16 @@ internal unsafe bool ValidateRequest(NativeRequestContext requestMemory)
internal unsafe bool ValidateAuth(NativeRequestContext requestMemory)
{
- if (!Settings.Authentication.AllowAnonymous && !requestMemory.CheckAuthenticated())
+ if (!Options.Authentication.AllowAnonymous && !requestMemory.CheckAuthenticated())
{
- SendError(requestMemory.RequestId, HttpStatusCode.Unauthorized,
- AuthenticationManager.GenerateChallenges(Settings.Authentication.Schemes));
+ SendError(requestMemory.RequestId, StatusCodes.Status401Unauthorized,
+ AuthenticationManager.GenerateChallenges(Options.Authentication.Schemes));
return false;
}
return true;
}
- private unsafe void SendError(ulong requestId, HttpStatusCode httpStatusCode, IList authChallenges)
+ private unsafe void SendError(ulong requestId, int httpStatusCode, IList authChallenges)
{
HttpApi.HTTP_RESPONSE_V2 httpResponse = new HttpApi.HTTP_RESPONSE_V2();
httpResponse.Response_V1.Version = new HttpApi.HTTP_VERSION();
diff --git a/src/Microsoft.Net.Http.Server/WebListenerSettings.cs b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysOptions.cs
similarity index 79%
rename from src/Microsoft.Net.Http.Server/WebListenerSettings.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/HttpSysOptions.cs
index cb54783..4d8e4cc 100644
--- a/src/Microsoft.Net.Http.Server/WebListenerSettings.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysOptions.cs
@@ -5,37 +5,33 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
-namespace Microsoft.Net.Http.Server
+namespace Microsoft.AspNetCore.Server.HttpSys
{
- public class WebListenerSettings
+ public class HttpSysOptions
{
private const long DefaultRequestQueueLength = 1000; // Http.sys default.
+ internal static readonly int DefaultMaxAccepts = 5 * Environment.ProcessorCount;
// The native request queue
private long _requestQueueLength = DefaultRequestQueueLength;
private RequestQueue _requestQueue;
private ILogger _logger = NullLogger.Instance;
- public WebListenerSettings()
+ public HttpSysOptions()
{
}
///
- /// The logger that will be used to create the WebListener instance. This should not be changed
- /// after creating the listener.
+ /// The maximum number of concurrent accepts.
///
- public ILogger Logger
- {
- get { return _logger; }
- set
- {
- if (value == null)
- {
- throw new ArgumentNullException(nameof(value));
- }
- _logger = value;
- }
- }
+ public int MaxAccepts { get; set; } = DefaultMaxAccepts;
+
+ ///
+ /// Attempts kernel mode caching for responses with eligible headers. The response may not include
+ /// Set-Cookie, Vary, or Pragma headers. It must include a Cache-Control header with Public and
+ /// either a Shared-Max-Age or Max-Age value, or an Expires header.
+ ///
+ public bool EnableResponseCaching { get; set; } = true;
///
/// The url prefixes to register with Http.Sys. These may be modified at any time prior to disposing
diff --git a/src/Microsoft.AspNetCore.Server.WebListener/LogHelper.cs b/src/Microsoft.AspNetCore.Server.HttpSys/LogHelper.cs
similarity index 84%
rename from src/Microsoft.AspNetCore.Server.WebListener/LogHelper.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/LogHelper.cs
index 70a8193..6442e08 100644
--- a/src/Microsoft.AspNetCore.Server.WebListener/LogHelper.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/LogHelper.cs
@@ -5,7 +5,7 @@
using System.Diagnostics;
using Microsoft.Extensions.Logging;
-namespace Microsoft.AspNetCore.Server.WebListener
+namespace Microsoft.AspNetCore.Server.HttpSys
{
internal static class LogHelper
{
@@ -31,6 +31,18 @@ internal static void LogInfo(ILogger logger, string data)
}
}
+ internal static void LogDebug(ILogger logger, string location, string data)
+ {
+ if (logger == null)
+ {
+ Debug.WriteLine(data);
+ }
+ else
+ {
+ logger.LogDebug(location + "; " + data);
+ }
+ }
+
internal static void LogDebug(ILogger logger, string location, Exception exception)
{
if (logger == null)
diff --git a/src/Microsoft.AspNetCore.Server.WebListener/MessagePump.cs b/src/Microsoft.AspNetCore.Server.HttpSys/MessagePump.cs
similarity index 93%
rename from src/Microsoft.AspNetCore.Server.WebListener/MessagePump.cs
rename to src/Microsoft.AspNetCore.Server.HttpSys/MessagePump.cs
index f88b4f1..bd6dbec 100644
--- a/src/Microsoft.AspNetCore.Server.WebListener/MessagePump.cs
+++ b/src/Microsoft.AspNetCore.Server.HttpSys/MessagePump.cs
@@ -11,13 +11,12 @@
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-using Microsoft.Net.Http.Server;
-namespace Microsoft.AspNetCore.Server.WebListener
+namespace Microsoft.AspNetCore.Server.HttpSys
{
internal class MessagePump : IServer
{
- private readonly Microsoft.Net.Http.Server.WebListener _listener;
+ private readonly HttpSysListener _listener;
private readonly ILogger _logger;
private IHttpApplication